[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1340295234-31613-1-git-send-email-beat-kueng@gmx.net>
Date: Thu, 21 Jun 2012 18:13:54 +0200
From: Beat Küng <beat-kueng@....net>
To: Stephen Boyd <sboyd@...eaurora.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org,
Beat Küng <beat-kueng@....net>
Subject: [PATCH 1/1] firmware: option to prevent firmware loading from userspace
Hello
Initially I had a problem with resuming from hibernation (debian testing amd64
system). The kernel would simply wait for 60 sec when trying to resume. I found
out that the resume thread was trying to aquire the user mode helper lock. Which
was held by the firmware loader (module iwlwifi) trying to load a firmware. But
there was no user space app to reply to the request so the kernel was waiting
for a timeout that is set to 60 seconds.
I use built-in firmware anyway, so there is no use to wait for user space to get
a firmware. So I came up with the following patch (applies to 3.5-rc3):
(It's my first patch and I'd like to get involved in kernel hacking, so any help
or recommendations are appreciated)
Only consider firmware built into the kernel binary when loading firmware.
This saves time waiting for a userspace application like udev or a
timeout if there is no userspace application. Especially if a driver is
looking for different versions of a firmware.
Signed-off-by: Beat Küng <beat-kueng@....net>
---
drivers/base/Kconfig | 10 ++++++++++
drivers/base/firmware_class.c | 8 ++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 9b21469..b0a2259 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -107,6 +107,16 @@ config FIRMWARE_IN_KERNEL
Say 'N' and let firmware be loaded from userspace.
+config FIRMWARE_DISABLE_USERSPACE
+ bool "Disable firmware loading from userspace"
+ depends on FIRMWARE_IN_KERNEL
+ default n
+ help
+ Only consider firmware built into the kernel binary when loading firmware.
+ This saves time waiting for a userspace application like udev or a
+ timeout if there is no userspace application. Especially if a driver is
+ looking for different versions of a firmware.
+
config EXTRA_FIRMWARE
string "External firmware blobs to build into the kernel binary"
depends on FW_LOADER
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5401814..7af8c3a 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -492,6 +492,14 @@ _request_firmware_prepare(const struct firmware **firmware_p, const char *name,
return NULL;
}
+#ifdef CONFIG_FIRMWARE_DISABLE_USERSPACE
+ dev_warn(device, "firmware: no built-in firmware %s. User space request is disabled\n"
+ , name);
+ release_firmware(firmware);
+ *firmware_p = NULL;
+ return NULL;
+#endif /* CONFIG_FIRMWARE_DISABLE_USERSPACE */
+
fw_priv = fw_create_instance(firmware, name, device, uevent, nowait);
if (IS_ERR(fw_priv)) {
release_firmware(firmware);
--
1.7.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists