public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] PM: Print a warning if firmware is requested when tasks are frozen
@ 2011-05-02 22:44 Rafael J. Wysocki
  2011-05-02 23:12 ` Greg KH
  2011-05-02 23:30 ` Valdis.Kletnieks
  0 siblings, 2 replies; 14+ messages in thread
From: Rafael J. Wysocki @ 2011-05-02 22:44 UTC (permalink / raw)
  To: LKML; +Cc: Linux PM mailing list, Greg Kroah-Hartman, Linus Torvalds

From: Rafael J. Wysocki <rjw@sisk.pl>

Some drivers erroneously use request_firmware() from their ->resume()
(or ->thaw(), or ->restore()) callbacks, which is not going to work
unless the firmware has been built in.  This causes system resume to
stall until the firmware-loading timeout expires, which makes users
think that the resume has failed and reboot their machines
unnecessarily.  For this reason, make _request_firmware() print a
warning when it has been called when tasks are frozen and it's
impossible to start any new usermode helpers.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/firmware_class.c |    3 +++
 include/linux/kmod.h          |    1 +
 kernel/kmod.c                 |    8 ++++++++
 3 files changed, 12 insertions(+)

Index: linux-2.6/include/linux/kmod.h
===================================================================
--- linux-2.6.orig/include/linux/kmod.h
+++ linux-2.6/include/linux/kmod.h
@@ -113,5 +113,6 @@ extern void usermodehelper_init(void);
 
 extern int usermodehelper_disable(void);
 extern void usermodehelper_enable(void);
+extern bool usermodehelper_is_disabled(void);
 
 #endif /* __LINUX_KMOD_H__ */
Index: linux-2.6/kernel/kmod.c
===================================================================
--- linux-2.6.orig/kernel/kmod.c
+++ linux-2.6/kernel/kmod.c
@@ -301,6 +301,14 @@ void usermodehelper_enable(void)
 	usermodehelper_disabled = 0;
 }
 
+/**
+ * usermodehelper_is_disabled - check if new helpers are allowed to be started
+ */
+bool usermodehelper_is_disabled(void)
+{
+	return usermodehelper_disabled;
+}
+
 static void helper_lock(void)
 {
 	atomic_inc(&running_helpers);
Index: linux-2.6/drivers/base/firmware_class.c
===================================================================
--- linux-2.6.orig/drivers/base/firmware_class.c
+++ linux-2.6/drivers/base/firmware_class.c
@@ -521,6 +521,9 @@ static int _request_firmware(const struc
 	if (!firmware_p)
 		return -EINVAL;
 
+	if (WARN_ON(usermodehelper_is_disabled()))
+		return -EBUSY;
+
 	*firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
 	if (!firmware) {
 		dev_err(device, "%s: kmalloc(struct firmware) failed\n",

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

end of thread, other threads:[~2011-05-03 18:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 22:44 [RFC][PATCH] PM: Print a warning if firmware is requested when tasks are frozen Rafael J. Wysocki
2011-05-02 23:12 ` Greg KH
2011-05-02 23:21   ` Linus Torvalds
2011-05-02 23:28     ` Greg KH
2011-05-03  0:59       ` Linus Torvalds
2011-05-03 14:05         ` Greg KH
2011-05-02 23:30 ` Valdis.Kletnieks
2011-05-03 11:02   ` Rafael J. Wysocki
2011-05-03 14:06     ` Greg KH
2011-05-03 17:12       ` Rafael J. Wysocki
2011-05-03 15:47     ` Valdis.Kletnieks
2011-05-03 15:56       ` Joe Perches
2011-05-03 17:14         ` Rafael J. Wysocki
     [not found]       ` <201105031914.18160.rjw@sisk.pl>
2011-05-03 18:03         ` Valdis.Kletnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox