firmware: add firmware_request_cache()
Subsystems (6)
Luis R. Rodriguez
maintainerv4 cover firmware: add firmware_request_cache()
Greg,
Here are the last straggler patches to clean up what was left which you requested and to add the new firmware_request_cache() call to fix a corner case suspend issue.
The extra space character you found in earlier patches no longer needs to be fixed as that assignement was replaced with a new line in later patches which does not have the extra space in the assignment. The only other straggler fix needed which you had pointed out was the debugfs typo.
The new API call was renamed as suggested to firmware_request_cache(), with the API name first. I'll use a separate series to start addressing the firmware API rename for the rest of the callers. That will take some time as I'm running quite a bit of tests on those changes and I am going to wait for 0-day to give me its blesssings.
Question, feedback, and specially rants are greatly appreciated.
Luis
Luis R. Rodriguez (3):
firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is
used
firmware: add firmware_request_cache() to help with cache on reboot
mt7601u: use firmware_request_cache() to address cache on reboot
.../driver-api/firmware/request_firmware.rst | 14 +++++++++++++ drivers/base/firmware_loader/fallback.c | 2 +- drivers/base/firmware_loader/main.c | 24 ++++++++++++++++++++++ drivers/net/wireless/mediatek/mt7601u/mcu.c | 2 +- include/linux/firmware.h | 3 +++ 5 files changed, 43 insertions(+), 2 deletions(-)
Signature · 1 line
2.16.2
Luis R. Rodriguez
maintainerPATCH v4 1/3 firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used
When the sysctl knob is used ignore the fallback mechanism we pr_info_once() to ensure its noted the knob was used. The print incorrectly states its a debugfs knob, its a sysctl knob, so correct this typo.
--- drivers/base/firmware_loader/fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/firmware_loader/fallback.c +1 -1
@@ -652,7 +652,7 @@ static bool fw_force_sysfs_fallback(unsigned int opt_flags)static bool fw_run_sysfs_fallback (unsigned int opt_flags) {if (fw_fallback_config.ignore_sysfs_fallback) { -pr_info_once ("Ignoring firmware sysfs fallback due to debugfs knob\n" ); +pr_info_once ("Ignoring firmware sysfs fallback due to sysctl knob\n" );return false; }
Signature · 1 line
2.16.2
Luis R. Rodriguez
maintainerPATCH v4 2/3 firmware: add firmware_request_cache() to help with cache on reboot
In reply to Luis R. RodriguezSome devices have an optimization in place to enable the firmware to be retaineed during a system reboot, so after reboot the device can skip requesting and loading the firmware. This can save up to 1s in load time. The mt7601u 802.11 device happens to be such a device.
When these devices retain the firmware on a reboot and then suspend they can miss looking for the firmware on resume. To help with this we need a way to cache the firmware when such an optimization has taken place.
--- .../driver-api/firmware/request_firmware.rst | 14 +++++++++++++ drivers/base/firmware_loader/main.c | 24 ++++++++++++++++++++++ include/linux/firmware.h | 3 +++ 3 files changed, 41 insertions(+)
Documentation/driver-api/firmware/request_firmware.rst +14 -0
@@ -44,6 +44,20 @@ request_firmware_nowait .. kernel-doc:: drivers/base/firmware_class.c :functions: request_firmware_nowait +Special optimizations on reboot +=============================== + +Some devices have an optimization in place to enable the firmware to be +retained during system reboot. When such optimizations are used the driver +author must ensure the firmware is still available on resume from suspend, +this can be done with firmware_request_cache() insted of requesting for the +firmare to be loaded. + +firmware_request_cache() +----------------------- +.. kernel-doc:: drivers/base/firmware_class.c + :functions: firmware_request_cache + request firmware API expected driver use ========================================
drivers/base/firmware_loader/main.c +24 -0
@@ -656,6 +656,30 @@ int request_firmware_direct(const struct firmware **firmware_p, }EXPORT_SYMBOL_GPL (request_firmware_direct); +/** +* firmware_request_cache: - cache firmware for suspend so resume can use it +* @name: name of firmware file +* @device: device for which firmware should be cached for +* +* There are some devices with an optimization that enables the device to not +* require loading firmware on system reboot. This optimization may still +* require the firmware present on resume from suspend. This routine can be +* used to ensure the firmware is present on resume from suspend in these +* situations. This helper is not compatible with drivers which use +* request_firmware_into_buf() or request_firmware_nowait() with no uevent set. +**/ +int firmware_request_cache (struct device *device,const char *name) +{ +int ret; + +mutex_lock (&fw_lock); + ret =fw_add_devm_name (device, name); +mutex_unlock (&fw_lock); + +return ret; +} +EXPORT_SYMBOL_GPL (firmware_request_cache); +/** * request_firmware_into_buf - load firmware into a previously allocated buffer * @firmware_p: pointer to firmware image
include/linux/firmware.h +3 -0
@@ -85,4 +85,7 @@ static inline int request_firmware_into_buf(const struct firmware **firmware_p, }#endif + +int firmware_request_cache (struct device *device,const char *name); +#endif
Signature · 1 line
2.16.2
Luis R. Rodriguez
maintainerPATCH v4 3/3 mt7601u: use firmware_request_cache() to address cache on reboot
In reply to Luis R. Rodriguezrequest_firmware_cache() will ensure the firmware is available on resume from suspend if on reboot the device retains the firmware.
This optimization is in place given otherwise on reboot we have to reload the firmware, the opmization saves us about max 1s, minimum 10ms.
Cantabile has reported back this fixes his woes with both suspend and hibernation.
--- drivers/net/wireless/mediatek/mt7601u/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt7601u/mcu.c +1 -1
@@ -420,7 +420,7 @@ static int mt7601u_load_firmware(struct mt7601u_dev *dev) MT_USB_DMA_CFG_TX_BULK_EN));if (firmware_running (dev)) -return 0 ; +return firmware_request_cache (dev->dev,MT7601U_FIRMWARE ); ret =request_firmware (&fw,MT7601U_FIRMWARE , dev->dev);if (ret)
Signature · 1 line
2.16.2