linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manuel Estrada Sainz <ranty@debian.org>
To: Andrew Morton <akpm@osdl.org>,
	Michael Hunold <hunold@convergence.de>,
	Marcel Holtmann <marcel@holtmann.org>,
	LKML <linux-kernel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] Proposal to remove workqueue usage from request_firmware_async()
Date: Tue, 21 Oct 2003 01:53:55 +0200	[thread overview]
Message-ID: <20031020235355.GA3068@ranty.pantax.net> (raw)

 How does this look?

 Interested parties please test and comment.

 ChangeLog:
	
	 In it's current form request_firmware sleeps for too long on
	 the system's common workqueue, and using a private workqueue as
	 previously proposed is not optimal. This patch creates one
	 kernel_thread for each request_firmware_async() invocation
	 which dies once the job is done.


 firmware_class.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)


Index: drivers/base/firmware_class.c
===================================================================
--- linux-2.5/drivers/base/firmware_class.c	(revision 14117)
+++ linux-2.5/drivers/base/firmware_class.c	(working copy)
@@ -415,18 +415,22 @@
 	void (*cont)(const struct firmware *fw, void *context);
 };
 
-static void
+static int
 request_firmware_work_func(void *arg)
 {
 	struct firmware_work *fw_work = arg;
 	const struct firmware *fw;
-	if (!arg)
-		return;
+	if (!arg) {
+		WARN_ON(1);
+		return 0;
+	}
+	daemonize("%s/%s", "firmware", fw_work->name);
 	request_firmware(&fw, fw_work->name, fw_work->device);
 	fw_work->cont(fw, fw_work->context);
 	release_firmware(fw);
 	module_put(fw_work->module);
 	kfree(fw_work);
+	return 0;
 }
 
 /**
@@ -451,6 +455,8 @@
 {
 	struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
 						GFP_ATOMIC);
+	int ret;
+
 	if (!fw_work)
 		return -ENOMEM;
 	if (!try_module_get(module)) {
@@ -465,9 +471,14 @@
 		.context = context,
 		.cont = cont,
 	};
-	INIT_WORK(&fw_work->work, request_firmware_work_func, fw_work);
 
-	schedule_work(&fw_work->work);
+	ret = kernel_thread(request_firmware_work_func, fw_work,
+			    CLONE_FS | CLONE_FILES);
+	
+	if (ret < 0) {
+		fw_work->cont(NULL, fw_work->context);
+		return ret;
+	}
 	return 0;
 }
 

-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.

             reply	other threads:[~2003-10-20 23:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-20 23:53 Manuel Estrada Sainz [this message]
2003-10-21  0:08 ` [PATCH] Proposal to remove workqueue usage from request_firmware_async() Andrew Morton
2003-10-21  9:37   ` Jorge Bernal
2003-10-21 12:44   ` Manuel Estrada Sainz
2003-10-21 12:56 ` Michael Hunold
2003-10-21 13:25 Manuel Estrada Sainz

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=20031020235355.GA3068@ranty.pantax.net \
    --to=ranty@debian.org \
    --cc=akpm@osdl.org \
    --cc=hunold@convergence.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).