From: Javier Pello <javier.pello@urjc.es>
To: linux-kernel@vger.kernel.org
Cc: Greg KH <greg@kroah.com>
Subject: [PATCH] request_firmware: skip timeout if userspace was not notified
Date: Fri, 03 Aug 2007 21:07:35 +0200 [thread overview]
Message-ID: <46B37CF7.2020803@urjc.es> (raw)
Hi,
I have prepared a patch that makes request_firmware skip the usual
grace period that it gives firmware images to show up, if it determines
that userspace was not notified at all.
When request_firmware is called, it sends an event to userspace to
ask for the firmware image that is needed, and then it installs a
timeout so that it will not wait forever for the image. However,
if userspace did not receive the event at all (no /sbin/hotplug,
for instance), then having the kernel wait is pointless. This is
particularly true during boot, when the wait is done synchronously
and the whole kernel freezes for a minute.
The attached patch fixes this by making _request_firmware check whether
the firmware loading event was succesfully sent to userspace, and skip
the timeout if it has not. The patch comes in two parts:
1. The first part changes kobject_uevent_env in lib/kobject_uevent.c
to report a failure if both netlink_broadcast (if applicable) and
call_usermodehelper fail to send the event to userspace. Nothing in
the kernel seems to care about the return value of kobject_uevent_env,
so this should not break anything.
2. The second part changes _request_firmware in
drivers/base/firmware_class.c to actually check the return value of
kobject_uevent and skip the loading_timeout delay if the loading event
was not delivered to userspace at all.
The patches apply cleanly against 2.6.23-rc1. Any suggestions or feedback
will be welcome.
Javier
PS Please CC: me on replies, as I am not subscribed to the list.
==========
From: Javier Pello <javier.pello@urjc.es>
kobject_uevent: return an error if event was not delivered to userspace
Make kobject_uevent_env return an error to the caller if the event was
not delivered to userspace either via netlink or via uevent_helper.
Signed-off-by: Javier Pello <javier.pello@urjc.es>
---
diff -u linux-2.6.22/lib/kobject_uevent.c linux-2.6.22-p/lib/kobject_uevent.c
--- linux-2.6.22/lib/kobject_uevent.c 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22-p/lib/kobject_uevent.c 2007-07-18 20:17:10.000000000 +0200
@@ -186,7 +186,8 @@
}
NETLINK_CB(skb).dst_group = 1;
- netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);
+ retval = netlink_broadcast(uevent_sock, skb, 0, 1,
+ GFP_KERNEL);
}
}
#endif
@@ -198,7 +199,18 @@
argv [0] = uevent_helper;
argv [1] = (char *)subsystem;
argv [2] = NULL;
- call_usermodehelper (argv[0], argv, envp, UMH_WAIT_EXEC);
+#if defined(CONFIG_NET)
+ if (retval) {
+ retval = call_usermodehelper (argv[0], argv, envp,
+ UMH_WAIT_EXEC);
+ } else {
+ call_usermodehelper (argv[0], argv, envp,
+ UMH_WAIT_EXEC);
+ }
+#else
+ retval = call_usermodehelper (argv[0], argv, envp,
+ UMH_WAIT_EXEC);
+#endif
}
exit:
==========
From: Javier Pello <javier.pello@urjc.es>
request_firmware: skip timeout if userspace was not notified
Stop _request_firmware from setting up a timer and waiting for
the firmware image to appear if kobject_uevent returns an error
(meaning userspace was not notified at all).
This prevents useless delays if there is no userspace tool to
provide the firmware image (eg during boot).
Signed-off-by: Javier Pello <javier.pello@urjc.es>
---
diff -u linux-2.6.22/drivers/base/firmware_class.c linux-2.6.22-p/drivers/base/firmware_class.c
--- linux-2.6.22/drivers/base/firmware_class.c 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22-p/drivers/base/firmware_class.c 2007-07-18 20:06:53.000000000 +0200
@@ -420,8 +420,12 @@
add_timer(&fw_priv->timeout);
}
- kobject_uevent(&f_dev->kobj, KOBJ_ADD);
- wait_for_completion(&fw_priv->completion);
+ retval = kobject_uevent(&f_dev->kobj, KOBJ_ADD);
+ if (retval) {
+ fw_load_abort(fw_priv);
+ } else {
+ wait_for_completion(&fw_priv->completion);
+ }
set_bit(FW_STATUS_DONE, &fw_priv->status);
del_timer_sync(&fw_priv->timeout);
} else
==========
next reply other threads:[~2007-08-03 19:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-03 19:07 Javier Pello [this message]
2007-08-04 5:21 ` [PATCH] request_firmware: skip timeout if userspace was not notified david
2007-08-04 8:50 ` Javier Pello
2007-08-04 17:09 ` david
2007-08-04 21:20 ` Javier Pello
2007-08-06 12:24 ` Cornelia Huck
2007-08-06 20:23 ` Javier Pello
[not found] ` <20070807125844.4d756b04@gondo lin.boeblingen.de.ibm.com>
2007-08-07 10:58 ` Cornelia Huck
2007-08-07 11:46 ` Kay Sievers
2007-08-07 12:10 ` Cornelia Huck
2007-08-07 12:31 ` Kay Sievers
2007-08-07 12:48 ` Cornelia Huck
2007-08-07 12:47 ` Javier Pello
2007-08-07 12:57 ` Kay Sievers
2007-08-07 13:15 ` Cornelia Huck
2007-08-07 13:59 ` Javier Pello
2007-08-07 14:08 ` Kay Sievers
2007-08-07 14:38 ` Cornelia Huck
2007-08-09 9:13 ` Javier Pello
2007-08-09 9:21 ` Kay Sievers
2007-08-09 9:26 ` Cornelia Huck
2007-08-07 14:26 ` Cornelia Huck
2007-08-09 9:36 ` Javier Pello
2007-08-09 11:58 ` Kay Sievers
2007-08-10 21:24 ` Javier Pello
2007-08-11 13:26 ` Kay Sievers
2007-08-07 20:05 ` Andrew Morton
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=46B37CF7.2020803@urjc.es \
--to=javier.pello@urjc.es \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.