Re: worker thread - filp_close() problem

From: Dmitry Torokhov
Date: Wed Nov 09 2011 - 13:13:05 EST


On Wed, Nov 09, 2011 at 08:52:12PM +0900, Murali K. Vemuri wrote:
> Hi there,
>
> I have a device driver where in I have to do like this:
>
> (I am using Kernel 2.6.32, and unfortunately cannot upgrade).
>
> 1. Register for an interrupt.
> 2. When I receive the interrupt, I do some processing, and schedule a
> worker for further processing after 25 msec.
> (The device data sheet says I have to give a minimum of 20 m sec).
> 3. The worker thread has to do some processing and then program
> another device connected to the serial port.
>
> Problem:
> 1. as long as I don't call the program_serial_dev() from
> my_dev_task(), everything is fine.
> 2. When I call the program_serial_dev(), I am, getting the error
> (console freezes as well):
> ------------[ cut here ]------------
> WARNING: at kernel/workqueue.c:485 flush_cpu_workqueue+0x34/0x88()
> [<c003f92c>] (unwind_backtrace+0x0/0xd8) from [<c006404c>]
> (warn_slowpath_common+0x48/0x60)

It looks like we end up trying to flush a workqueue from within a work
item, which deadlocks.

Since you are using threaded IRQ just stick msleep(25) there and call
program_serial_dev() from it.

... But from the looks of things the programming should not be done in
kernel but rather from userspace...

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