From patchwork Mon May 2 22:44:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 748562 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p42MoJaI002754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 2 May 2011 22:50:40 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p42MjOSq004476; Mon, 2 May 2011 15:45:54 -0700 Received: from ogre.sisk.pl (ogre.sisk.pl [217.79.144.158]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p42MiLKb004365 for ; Mon, 2 May 2011 15:44:23 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 2F0801AD889; Tue, 3 May 2011 00:40:15 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04134-08; Tue, 3 May 2011 00:39:53 +0200 (CEST) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 1316C1AD67E; Tue, 3 May 2011 00:39:53 +0200 (CEST) From: "Rafael J. Wysocki" To: LKML Date: Tue, 3 May 2011 00:44:51 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.39-rc5+; KDE/4.6.0; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201105030044.51661.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-5.438 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: Linux PM mailing list , Greg Kroah-Hartman , Linus Torvalds Subject: [linux-pm] [RFC][PATCH] PM: Print a warning if firmware is requested when tasks are frozen X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 02 May 2011 22:50:40 +0000 (UTC) From: Rafael J. Wysocki 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 --- 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",