All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] firmware: add firmware_request_cache()
@ 2018-03-21 22:34 Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 1/3] firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used Luis R. Rodriguez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2018-03-21 22:34 UTC (permalink / raw)
  To: gregkh
  Cc: akpm, cantabile.desu, kubakici, linux-wireless, keescook, shuah,
	mfuzzey, zohar, dhowells, pali.rohar, tiwai, arend.vanspriel,
	zajec5, nbroeking, markivx, broonie, dmitry.torokhov, dwmw2,
	torvalds, Abhay_Salunke, bjorn.andersson, jewalt, oneukum, ast,
	andresx7, linux-kernel, linux-fsdevel, Luis R. Rodriguez

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(-)

-- 
2.16.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v4 1/3] firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used
  2018-03-21 22:34 [PATCH v4 0/3] firmware: add firmware_request_cache() Luis R. Rodriguez
@ 2018-03-21 22:34 ` Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 2/3] firmware: add firmware_request_cache() to help with cache on reboot Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 3/3] mt7601u: use firmware_request_cache() to address " Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2018-03-21 22:34 UTC (permalink / raw)
  To: gregkh
  Cc: akpm, cantabile.desu, kubakici, linux-wireless, keescook, shuah,
	mfuzzey, zohar, dhowells, pali.rohar, tiwai, arend.vanspriel,
	zajec5, nbroeking, markivx, broonie, dmitry.torokhov, dwmw2,
	torvalds, Abhay_Salunke, bjorn.andersson, jewalt, oneukum, ast,
	andresx7, linux-kernel, linux-fsdevel, Luis R. Rodriguez

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.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 drivers/base/firmware_loader/fallback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index d231bbcb95d7..31b5015b59fe 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -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;
 	}
 
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 2/3] firmware: add firmware_request_cache() to help with cache on reboot
  2018-03-21 22:34 [PATCH v4 0/3] firmware: add firmware_request_cache() Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 1/3] firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used Luis R. Rodriguez
@ 2018-03-21 22:34 ` Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 3/3] mt7601u: use firmware_request_cache() to address " Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2018-03-21 22:34 UTC (permalink / raw)
  To: gregkh
  Cc: akpm, cantabile.desu, kubakici, linux-wireless, keescook, shuah,
	mfuzzey, zohar, dhowells, pali.rohar, tiwai, arend.vanspriel,
	zajec5, nbroeking, markivx, broonie, dmitry.torokhov, dwmw2,
	torvalds, Abhay_Salunke, bjorn.andersson, jewalt, oneukum, ast,
	andresx7, linux-kernel, linux-fsdevel, Luis R. Rodriguez

Some 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.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 .../driver-api/firmware/request_firmware.rst       | 14 +++++++++++++
 drivers/base/firmware_loader/main.c                | 24 ++++++++++++++++++++++
 include/linux/firmware.h                           |  3 +++
 3 files changed, 41 insertions(+)

diff --git a/Documentation/driver-api/firmware/request_firmware.rst b/Documentation/driver-api/firmware/request_firmware.rst
index cc0aea880824..cf4516dfbf96 100644
--- a/Documentation/driver-api/firmware/request_firmware.rst
+++ b/Documentation/driver-api/firmware/request_firmware.rst
@@ -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
 ========================================
 
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 2913bb0e5e7b..eb34089e4299 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -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
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index d4508080348d..41050417cafb 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -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
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 3/3] mt7601u: use firmware_request_cache() to address cache on reboot
  2018-03-21 22:34 [PATCH v4 0/3] firmware: add firmware_request_cache() Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 1/3] firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used Luis R. Rodriguez
  2018-03-21 22:34 ` [PATCH v4 2/3] firmware: add firmware_request_cache() to help with cache on reboot Luis R. Rodriguez
@ 2018-03-21 22:34 ` Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2018-03-21 22:34 UTC (permalink / raw)
  To: gregkh
  Cc: akpm, cantabile.desu, kubakici, linux-wireless, keescook, shuah,
	mfuzzey, zohar, dhowells, pali.rohar, tiwai, arend.vanspriel,
	zajec5, nbroeking, markivx, broonie, dmitry.torokhov, dwmw2,
	torvalds, Abhay_Salunke, bjorn.andersson, jewalt, oneukum, ast,
	andresx7, linux-kernel, linux-fsdevel, Luis R. Rodriguez

request_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.

Reported-by: Cantabile <cantabile.desu@gmail.com>
Tested-by: Cantabile <cantabile.desu@gmail.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 drivers/net/wireless/mediatek/mt7601u/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/mcu.c b/drivers/net/wireless/mediatek/mt7601u/mcu.c
index d9d6fd7eff5e..61705f679856 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mcu.c
+++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
@@ -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)
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-21 22:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 22:34 [PATCH v4 0/3] firmware: add firmware_request_cache() Luis R. Rodriguez
2018-03-21 22:34 ` [PATCH v4 1/3] firmware: fix typo on pr_info_once() when ignore_sysfs_fallback is used Luis R. Rodriguez
2018-03-21 22:34 ` [PATCH v4 2/3] firmware: add firmware_request_cache() to help with cache on reboot Luis R. Rodriguez
2018-03-21 22:34 ` [PATCH v4 3/3] mt7601u: use firmware_request_cache() to address " Luis R. Rodriguez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.