aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikram Mulukutla <markivx@codeaurora.org>2016-08-02 17:04:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:09 -0400
commit0e742e927571946e08e877d3629e6efd4891ed95 (patch)
tree0dbc66bd15655c8fa0b3761a5a9fdd1bdb894c44
parent9ccf98119821defe66ee2ee21f8a11071f63fa65 (diff)
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/20160607164741.31849-3-stephen.boyd@linaro.org [stephen.boyd@linaro.org: Drop firmware_desc design and use flags] Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com> Cc: Mark Brown <broonie@kernel.org> Cc: Ming Lei <ming.lei@canonical.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/base/firmware_class.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 01d55723d82c..45ed20cefa10 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -112,6 +112,7 @@ static inline long firmware_loading_timeout(void)
112#define FW_OPT_FALLBACK 0 112#define FW_OPT_FALLBACK 0
113#endif 113#endif
114#define FW_OPT_NO_WARN (1U << 3) 114#define FW_OPT_NO_WARN (1U << 3)
115#define FW_OPT_NOCACHE (1U << 4)
115 116
116struct firmware_cache { 117struct firmware_cache {
117 /* firmware_buf instance will be added into the below list */ 118 /* 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,
1065 * should be fixed in devres or driver core. 1066 * should be fixed in devres or driver core.
1066 */ 1067 */
1067 /* don't cache firmware handled without uevent */ 1068 /* 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))
1069 fw_add_devm_name(device, buf->fw_id); 1071 fw_add_devm_name(device, buf->fw_id);
1070 1072
1071 /* 1073 /*
1072 * After caching firmware image is started, let it piggyback 1074 * After caching firmware image is started, let it piggyback
1073 * on request firmware. 1075 * on request firmware.
1074 */ 1076 */
1075 if (buf->fwc->state == FW_LOADER_START_CACHE) { 1077 if (!(opt_flags & FW_OPT_NOCACHE) &&
1078 buf->fwc->state == FW_LOADER_START_CACHE) {
1076 if (fw_cache_piggyback_on_request(buf->fw_id)) 1079 if (fw_cache_piggyback_on_request(buf->fw_id))
1077 kref_get(&buf->ref); 1080 kref_get(&buf->ref);
1078 } 1081 }