mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Ming Lei <ming.lei@canonical.com>,
	Takashi Iwai <tiwai@suse.de>
Subject: [PATCH 2/2] driver core: firmware loader: kill FW_ACTION_NOHOTPLUG requests before suspend
Date: Mon, 27 May 2013 18:30:04 +0800	[thread overview]
Message-ID: <1369650604-27941-3-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1369650604-27941-1-git-send-email-ming.lei@canonical.com>

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.

Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---

This patch depends on Takashi Iwai's patch of "firmware: Avoid deadlock of
usermodehelper lock at shutdown"

 drivers/base/firmware_class.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 64e7870..5690e72 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -128,6 +128,7 @@ struct firmware_buf {
 	size_t size;
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 	bool is_paged_buf;
+	bool need_uevent;
 	struct page **pages;
 	int nr_pages;
 	int page_array_size;
@@ -873,6 +874,7 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
 	}
 
 	if (uevent) {
+		buf->need_uevent = true;
 		dev_set_uevent_suppress(f_dev, false);
 		dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
 		if (timeout != MAX_SCHEDULE_TIMEOUT)
@@ -1407,6 +1409,20 @@ static void __device_uncache_fw_images(void)
 	spin_unlock(&fwc->name_lock);
 }
 
+/* kill pending requests without uevent to avoid blocking suspend */
+static void kill_requests_without_uevent(void)
+{
+	struct firmware_buf *buf;
+	struct firmware_buf *next;
+
+	mutex_lock(&fw_lock);
+	list_for_each_entry_safe(buf, next, &pending_fw_head, pending_list) {
+		if (!buf->need_uevent)
+			 fw_load_abort(buf);
+	}
+	mutex_unlock(&fw_lock);
+}
+
 /**
  * device_cache_fw_images - cache devices' firmware
  *
@@ -1486,6 +1502,7 @@ static int fw_pm_notify(struct notifier_block *notify_block,
 	switch (mode) {
 	case PM_HIBERNATION_PREPARE:
 	case PM_SUSPEND_PREPARE:
+		kill_requests_without_uevent();
 		device_cache_fw_images();
 		break;
 
-- 
1.7.9.5


  parent reply	other threads:[~2013-05-27 10:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-27 10:30 [PATCH 0/2] firmware loader: avoid blocking suspend by !uevent requests Ming Lei
2013-05-27 10:30 ` [PATCH 1/2] driver core: firmware loader: don't cache FW_ACTION_NOHOTPLUG firmware Ming Lei
2013-05-27 11:56   ` anish singh
2013-05-27 12:23     ` Takashi Iwai
2013-05-27 12:40       ` anish singh
2013-05-27 13:22         ` Ming Lei
2013-05-27 17:01           ` anish singh
2013-05-27 12:24   ` Takashi Iwai
2013-05-27 10:30 ` Ming Lei [this message]
2013-05-27 12:24   ` [PATCH 2/2] driver core: firmware loader: kill FW_ACTION_NOHOTPLUG requests before suspend Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369650604-27941-3-git-send-email-ming.lei@canonical.com \
    --to=ming.lei@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®