lkml.org 
[lkml]   [2013]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] irq: add a new function irq_in_progress to check pending IRQ handlers
On Thu, 6 Jun 2013, shuox.liu@intel.com wrote:
> From: Zhang Yanmin <yanmin.zhang@intel.com>
>
> synchronize_irq waits pending IRQ handlers to be finished. If using this
> function while holding a resource, the IRQ handler may cause deadlock.
>
> Here we add a new function irq_in_progress which doesn't wait for the handlers
> to be finished.
>
> A typical use case at suspend-to-ram:
>
> device driver's irq handler is complicated and might hold a mutex at rare cases.
> Its suspend function is called and a suspended flag is set.
> In case its IRQ handler is running, suspend function calls irq_in_progress. if
> handler is running, abort suspend.
> The irq handler checks the suspended flag. If the device is suspended, irq handler
> either ignores the interrupt, or wakes up the whole system, and the driver's
> resume function could deal with the delayed interrupt handling.

This is as wrong as it can be. Fix the driver instead of hacking racy
functions into the core code.

So your problem looks like this:

CPU 0 CPU 1
irq_handler_thread() suspend()
..... mutex_lock(&m);
mutex_lock(&m); synchronize_irq();

So why needs the mutex to be taken before synchronize_irq()? Why not
doing the obvious?

suspend()
disable_irq(); (Implies synchronize_irq)
mutex_lock(&m);
....
mutex_unlock(&m);
enable_irq();

Thanks,

tglx


\
 
 \ /
  Last update: 2013-06-06 16:01    [W:0.042 / U:4.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site