All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: add firmware to new device's devres list for second time cache
@ 2017-08-22  7:52 Kai-Heng Feng
  2017-09-16  4:46 ` Kai-Heng Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kai-Heng Feng @ 2017-08-22  7:52 UTC (permalink / raw)
  To: mcgrof; +Cc: gregkh, linux-kernel, Kai-Heng Feng

Currently, firmware will only be chached if assign_firmware_buf() gets
called.

When a device loses its power or a USB device gets plugged to another
port under suspend, request_firmware() can still find cached firmware,
but firmware name no longer associates with the new device's devres.
So next time the system suspend, those firmware won't be cached.

Hence, we should add the firmware name to the devres when the firmware
is found in cache, to make the firmware cacheable next time.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/base/firmware_class.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index bfbe1e154128..a99de34e3fdc 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1177,6 +1177,10 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
 
 	ret = fw_lookup_and_allocate_buf(name, &fw_cache, &buf, dbuf, size);
 
+	/* device might be a new one, add it to devres list */
+	if (ret == 0 || ret == 1)
+		fw_add_devm_name(device, name);
+
 	/*
 	 * bind with 'buf' now to avoid warning in failure path
 	 * of requesting firmware.
-- 
2.14.1

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

end of thread, other threads:[~2017-10-06  4:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22  7:52 [PATCH] firmware: add firmware to new device's devres list for second time cache Kai-Heng Feng
2017-09-16  4:46 ` Kai-Heng Feng
2017-10-04  7:24 ` Greg KH
2017-10-04 21:17 ` Luis R. Rodriguez
2017-10-06  4:55   ` Kai-Heng Feng

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.