Skip to content

Commit 0e742e9

Browse files
Vikram Mulukutlatorvalds
authored andcommitted
firmware: provide infrastructure to make fw caching optional
Some low memory systems with complex peripherals cannot afford to have the relatively large firmware images taking up valuable memory during suspend and resume. Change the internal implementation of firmware_class to disallow caching based on a configurable option. In the near future, variants of request_firmware will take advantage of this feature. Link: http://lkml.kernel.org/r/[email protected] [[email protected]: Drop firmware_desc design and use flags] Signed-off-by: Vikram Mulukutla <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Cc: Mimi Zohar <[email protected]> Cc: Mark Brown <[email protected]> Cc: Ming Lei <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9ccf981 commit 0e742e9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/base/firmware_class.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static inline long firmware_loading_timeout(void)
112112
#define FW_OPT_FALLBACK 0
113113
#endif
114114
#define FW_OPT_NO_WARN (1U << 3)
115+
#define FW_OPT_NOCACHE (1U << 4)
115116

116117
struct firmware_cache {
117118
/* firmware_buf instance will be added into the below list */
@@ -1065,14 +1066,16 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
10651066
* should be fixed in devres or driver core.
10661067
*/
10671068
/* don't cache firmware handled without uevent */
1068-
if (device && (opt_flags & FW_OPT_UEVENT))
1069+
if (device && (opt_flags & FW_OPT_UEVENT) &&
1070+
!(opt_flags & FW_OPT_NOCACHE))
10691071
fw_add_devm_name(device, buf->fw_id);
10701072

10711073
/*
10721074
* After caching firmware image is started, let it piggyback
10731075
* on request firmware.
10741076
*/
1075-
if (buf->fwc->state == FW_LOADER_START_CACHE) {
1077+
if (!(opt_flags & FW_OPT_NOCACHE) &&
1078+
buf->fwc->state == FW_LOADER_START_CACHE) {
10761079
if (fw_cache_piggyback_on_request(buf->fw_id))
10771080
kref_get(&buf->ref);
10781081
}

0 commit comments

Comments
 (0)