All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Proposal to remove workqueue usage from request_firmware_async()
@ 2003-10-20 23:53 Manuel Estrada Sainz
  2003-10-21  0:08 ` Andrew Morton
  2003-10-21 12:56 ` Michael Hunold
  0 siblings, 2 replies; 6+ messages in thread
From: Manuel Estrada Sainz @ 2003-10-20 23:53 UTC (permalink / raw)
  To: Andrew Morton, Michael Hunold, Marcel Holtmann, LKML; +Cc: LKML

 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.

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

* Re: [PATCH] Proposal to remove workqueue usage from request_firmware_async()
  2003-10-20 23:53 [PATCH] Proposal to remove workqueue usage from request_firmware_async() Manuel Estrada Sainz
@ 2003-10-21  0:08 ` Andrew Morton
  2003-10-21  9:37   ` Jorge Bernal
  2003-10-21 12:44   ` Manuel Estrada Sainz
  2003-10-21 12:56 ` Michael Hunold
  1 sibling, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2003-10-21  0:08 UTC (permalink / raw)
  To: ranty; +Cc: hunold, marcel, linux-kernel

Manuel Estrada Sainz <ranty@debian.org> wrote:
>
>  How does this look?

OK I guess.  I assume it works?

> +	daemonize("%s/%s", "firmware", fw_work->name);

	daemonize("firmware/%s", "fw_work->name);


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

* Re: [PATCH] Proposal to remove workqueue usage from request_firmware_async()
  2003-10-21  0:08 ` Andrew Morton
@ 2003-10-21  9:37   ` Jorge Bernal
  2003-10-21 12:44   ` Manuel Estrada Sainz
  1 sibling, 0 replies; 6+ messages in thread
From: Jorge Bernal @ 2003-10-21  9:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ranty, hunold, marcel, linux-kernel

On Mon, Oct 20, 2003 at 05:08:04PM -0700, Andrew Morton wrote:
> 	daemonize("firmware/%s", "fw_work->name);
daemonize("firmware/%s", fw_work->name);

> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
"Dios es real, a no ser que sea declarado como entero"

Jorge Bernal "Koke" http://sindominio.net/~koke/
Jabber-ID: koke@zgzjabber.ath.cx
<koke@sindominio.net> || <kokecillo@eresmas.com>
.: www.augustux.org   ::	pulsar.gotdns.org	 :.

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

* Re: [PATCH] Proposal to remove workqueue usage from request_firmware_async()
  2003-10-21  0:08 ` Andrew Morton
  2003-10-21  9:37   ` Jorge Bernal
@ 2003-10-21 12:44   ` Manuel Estrada Sainz
  1 sibling, 0 replies; 6+ messages in thread
From: Manuel Estrada Sainz @ 2003-10-21 12:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: hunold, marcel, linux-kernel

On Mon, Oct 20, 2003 at 05:08:04PM -0700, Andrew Morton wrote:
> Manuel Estrada Sainz <ranty@debian.org> wrote:
> >
> >  How does this look?
> 
> OK I guess.  I assume it works?

 Yes, it works. Although I didn't do heavy testing and it is the first
 time I play with kernel threads durectly, so I may be doing something
 stupid.
 
> > +	daemonize("%s/%s", "firmware", fw_work->name);
> 
> 	daemonize("firmware/%s", "fw_work->name);

 Dumb me, I'll resend with that.

 Regards

 	Manuel

-- 
--- 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.

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

* Re: [PATCH] Proposal to remove workqueue usage from request_firmware_async()
  2003-10-20 23:53 [PATCH] Proposal to remove workqueue usage from request_firmware_async() Manuel Estrada Sainz
  2003-10-21  0:08 ` Andrew Morton
@ 2003-10-21 12:56 ` Michael Hunold
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Hunold @ 2003-10-21 12:56 UTC (permalink / raw)
  To: ranty; +Cc: Andrew Morton, Marcel Holtmann, LKML

Hello Manuel,

>  How does this look?
>  Interested parties please test and comment.

I updated my patch for the av7110 DVB driver from LinuxTV.org and I can 
confirm that it works very well.

Recent updates are in
http://linuxtv.org/cgi-bin/cvsweb.cgi/dvb-kernel/patches-2.6/

I usually set the timeout value to "60" and then manually load the 
firmware. Everything is ok, IMHO this patch can be submitted.

CU
Michael.


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

* [PATCH] Proposal to remove workqueue usage from request_firmware_async()
@ 2003-10-21 13:25 Manuel Estrada Sainz
  0 siblings, 0 replies; 6+ messages in thread
From: Manuel Estrada Sainz @ 2003-10-21 13:25 UTC (permalink / raw)
  To: Andrew Morton, LKML

 Michael Hunold also confirmed that it works for him, IMHO it should be
 safe at least for the -mm tree.

 The only difference with the previous patch is:

	 -daemonize("%s/%s", "firmware", fw_work->name);
	 +daemonize("firmware/%s", fw_work->name);

 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("firmware/%s", 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.

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

end of thread, other threads:[~2003-10-21 13:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-20 23:53 [PATCH] Proposal to remove workqueue usage from request_firmware_async() Manuel Estrada Sainz
2003-10-21  0:08 ` 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

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.