Skip to content

Commit af5bc11

Browse files
Ming Leigregkh
authored andcommitted
driver core: firmware loader: kill FW_ACTION_NOHOTPLUG requests before suspend
This patch kills the firmware loading requests of FW_ACTION_NOHOTPLUG before suspend to avoid blocking suspend because there is no timeout for these requests. Signed-off-by: Ming Lei <ming.lei@canonical.com> Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e771d1a commit af5bc11

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎drivers/base/firmware_class.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct firmware_buf {
128128
size_t size;
129129
#ifdef CONFIG_FW_LOADER_USER_HELPER
130130
bool is_paged_buf;
131+
bool need_uevent;
131132
struct page **pages;
132133
int nr_pages;
133134
int page_array_size;
@@ -873,6 +874,7 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
873874
}
874875

875876
if (uevent) {
877+
buf->need_uevent = true;
876878
dev_set_uevent_suppress(f_dev, false);
877879
dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
878880
if (timeout != MAX_SCHEDULE_TIMEOUT)
@@ -1412,6 +1414,20 @@ static void __device_uncache_fw_images(void)
14121414
spin_unlock(&fwc->name_lock);
14131415
}
14141416

1417+
/* kill pending requests without uevent to avoid blocking suspend */
1418+
static void kill_requests_without_uevent(void)
1419+
{
1420+
struct firmware_buf *buf;
1421+
struct firmware_buf *next;
1422+
1423+
mutex_lock(&fw_lock);
1424+
list_for_each_entry_safe(buf, next, &pending_fw_head, pending_list) {
1425+
if (!buf->need_uevent)
1426+
fw_load_abort(buf);
1427+
}
1428+
mutex_unlock(&fw_lock);
1429+
}
1430+
14151431
/**
14161432
* device_cache_fw_images - cache devices' firmware
14171433
*
@@ -1491,6 +1507,7 @@ static int fw_pm_notify(struct notifier_block *notify_block,
14911507
switch (mode) {
14921508
case PM_HIBERNATION_PREPARE:
14931509
case PM_SUSPEND_PREPARE:
1510+
kill_requests_without_uevent();
14941511
device_cache_fw_images();
14951512
break;
14961513

0 commit comments

Comments
 (0)