* [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
@ 2014-04-05 20:54 Alexey Khoroshilov
2014-04-06 20:24 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Khoroshilov @ 2014-04-05 20:54 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, linux-kernel, ldv-project, Alexey Khoroshilov
pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
pcap_keys_handler() is registered as nonthreaded irq handler,
that means sleeping function is called in irq handler.
The patch makes a switch to threaded irq handling.
Compile tested only.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/input/misc/pcap_keys.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
index cd230365166e..2a10f3a30969 100644
--- a/drivers/input/misc/pcap_keys.c
+++ b/drivers/input/misc/pcap_keys.c
@@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
if (err)
goto fail_allocate;
- err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
- pcap_keys_handler, 0, "Power key", pcap_keys);
+ err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
+ NULL, pcap_keys_handler, 0,
+ "Power key", pcap_keys);
if (err)
goto fail_register;
- err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
- pcap_keys_handler, 0, "Headphone button", pcap_keys);
+ err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
+ NULL, pcap_keys_handler, 0,
+ "Headphone button", pcap_keys);
if (err)
goto fail_pwrkey;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
2014-04-05 20:54 [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler Alexey Khoroshilov
@ 2014-04-06 20:24 ` Dmitry Torokhov
2014-04-06 21:37 ` Antonio Ospite
2014-05-21 9:17 ` Antonio Ospite
0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2014-04-06 20:24 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: linux-input, linux-kernel, ldv-project, Daniel Ribeiro,
Ilya Petrov, Antonio Ospite
On Sun, Apr 06, 2014 at 12:54:50AM +0400, Alexey Khoroshilov wrote:
> pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
> pcap_keys_handler() is registered as nonthreaded irq handler,
> that means sleeping function is called in irq handler.
>
> The patch makes a switch to threaded irq handling.
> Compile tested only.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/input/misc/pcap_keys.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
> index cd230365166e..2a10f3a30969 100644
> --- a/drivers/input/misc/pcap_keys.c
> +++ b/drivers/input/misc/pcap_keys.c
> @@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
> if (err)
> goto fail_allocate;
>
> - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> - pcap_keys_handler, 0, "Power key", pcap_keys);
> + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> + NULL, pcap_keys_handler, 0,
> + "Power key", pcap_keys);
> if (err)
> goto fail_register;
>
> - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> - pcap_keys_handler, 0, "Headphone button", pcap_keys);
> + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> + NULL, pcap_keys_handler, 0,
> + "Headphone button", pcap_keys);
So I guess we do need threaded IRQ here, but I do not see the pcap's
irqchip specifying IRQCHIP_ONESHOT_SAFE so I do not think
request_threaded_irq() without IRQF_ONESHOT would succeed.
Can someone test the change to be sure?
Thanks!
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
2014-04-06 20:24 ` Dmitry Torokhov
@ 2014-04-06 21:37 ` Antonio Ospite
2014-05-13 2:14 ` Dmitry Torokhov
2014-05-21 9:17 ` Antonio Ospite
1 sibling, 1 reply; 6+ messages in thread
From: Antonio Ospite @ 2014-04-06 21:37 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Alexey Khoroshilov, linux-input, linux-kernel, ldv-project,
Daniel Ribeiro, Ilya Petrov, Antonio Ospite
On Sun, 6 Apr 2014 13:24:36 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Sun, Apr 06, 2014 at 12:54:50AM +0400, Alexey Khoroshilov wrote:
> > pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
> > pcap_keys_handler() is registered as nonthreaded irq handler,
> > that means sleeping function is called in irq handler.
> >
> > The patch makes a switch to threaded irq handling.
> > Compile tested only.
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> > ---
> > drivers/input/misc/pcap_keys.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
> > index cd230365166e..2a10f3a30969 100644
> > --- a/drivers/input/misc/pcap_keys.c
> > +++ b/drivers/input/misc/pcap_keys.c
> > @@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
> > if (err)
> > goto fail_allocate;
> >
> > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > - pcap_keys_handler, 0, "Power key", pcap_keys);
> > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > + NULL, pcap_keys_handler, 0,
> > + "Power key", pcap_keys);
> > if (err)
> > goto fail_register;
> >
> > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > - pcap_keys_handler, 0, "Headphone button", pcap_keys);
> > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > + NULL, pcap_keys_handler, 0,
> > + "Headphone button", pcap_keys);
>
> So I guess we do need threaded IRQ here, but I do not see the pcap's
> irqchip specifying IRQCHIP_ONESHOT_SAFE so I do not think
> request_threaded_irq() without IRQF_ONESHOT would succeed.
>
> Can someone test the change to be sure?
>
I can try to test it in a couple of weeks, I don't have the hardware
at hand right now.
Ciao,
Antonio
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
2014-04-06 21:37 ` Antonio Ospite
@ 2014-05-13 2:14 ` Dmitry Torokhov
2014-05-13 8:13 ` Antonio Ospite
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2014-05-13 2:14 UTC (permalink / raw)
To: Antonio Ospite
Cc: Alexey Khoroshilov, linux-input, linux-kernel, ldv-project,
Daniel Ribeiro, Ilya Petrov, Antonio Ospite
On Sun, Apr 06, 2014 at 11:37:44PM +0200, Antonio Ospite wrote:
> On Sun, 6 Apr 2014 13:24:36 -0700
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
>
> > On Sun, Apr 06, 2014 at 12:54:50AM +0400, Alexey Khoroshilov wrote:
> > > pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
> > > pcap_keys_handler() is registered as nonthreaded irq handler,
> > > that means sleeping function is called in irq handler.
> > >
> > > The patch makes a switch to threaded irq handling.
> > > Compile tested only.
> > >
> > > Found by Linux Driver Verification project (linuxtesting.org).
> > >
> > > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> > > ---
> > > drivers/input/misc/pcap_keys.c | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
> > > index cd230365166e..2a10f3a30969 100644
> > > --- a/drivers/input/misc/pcap_keys.c
> > > +++ b/drivers/input/misc/pcap_keys.c
> > > @@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
> > > if (err)
> > > goto fail_allocate;
> > >
> > > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > > - pcap_keys_handler, 0, "Power key", pcap_keys);
> > > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > > + NULL, pcap_keys_handler, 0,
> > > + "Power key", pcap_keys);
> > > if (err)
> > > goto fail_register;
> > >
> > > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > > - pcap_keys_handler, 0, "Headphone button", pcap_keys);
> > > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > > + NULL, pcap_keys_handler, 0,
> > > + "Headphone button", pcap_keys);
> >
> > So I guess we do need threaded IRQ here, but I do not see the pcap's
> > irqchip specifying IRQCHIP_ONESHOT_SAFE so I do not think
> > request_threaded_irq() without IRQF_ONESHOT would succeed.
> >
> > Can someone test the change to be sure?
> >
>
> I can try to test it in a couple of weeks, I don't have the hardware
> at hand right now.
Antonio, did you have a chance to try this out yet?
Thanks!
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
2014-05-13 2:14 ` Dmitry Torokhov
@ 2014-05-13 8:13 ` Antonio Ospite
0 siblings, 0 replies; 6+ messages in thread
From: Antonio Ospite @ 2014-05-13 8:13 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Alexey Khoroshilov, linux-input, linux-kernel, ldv-project,
Daniel Ribeiro, Ilya Petrov, Antonio Ospite
On Mon, 12 May 2014 19:14:56 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Sun, Apr 06, 2014 at 11:37:44PM +0200, Antonio Ospite wrote:
> > On Sun, 6 Apr 2014 13:24:36 -0700
> > Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> >
> > > On Sun, Apr 06, 2014 at 12:54:50AM +0400, Alexey Khoroshilov wrote:
> > > > pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
> > > > pcap_keys_handler() is registered as nonthreaded irq handler,
> > > > that means sleeping function is called in irq handler.
> > > >
> > > > The patch makes a switch to threaded irq handling.
> > > > Compile tested only.
> > > >
> > > > Found by Linux Driver Verification project (linuxtesting.org).
> > > >
> > > > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> > > > ---
> > > > drivers/input/misc/pcap_keys.c | 10 ++++++----
> > > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
> > > > index cd230365166e..2a10f3a30969 100644
> > > > --- a/drivers/input/misc/pcap_keys.c
> > > > +++ b/drivers/input/misc/pcap_keys.c
> > > > @@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
> > > > if (err)
> > > > goto fail_allocate;
> > > >
> > > > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > > > - pcap_keys_handler, 0, "Power key", pcap_keys);
> > > > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > > > + NULL, pcap_keys_handler, 0,
> > > > + "Power key", pcap_keys);
> > > > if (err)
> > > > goto fail_register;
> > > >
> > > > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > > > - pcap_keys_handler, 0, "Headphone button", pcap_keys);
> > > > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > > > + NULL, pcap_keys_handler, 0,
> > > > + "Headphone button", pcap_keys);
> > >
> > > So I guess we do need threaded IRQ here, but I do not see the pcap's
> > > irqchip specifying IRQCHIP_ONESHOT_SAFE so I do not think
> > > request_threaded_irq() without IRQF_ONESHOT would succeed.
> > >
> > > Can someone test the change to be sure?
> > >
> >
> > I can try to test it in a couple of weeks, I don't have the hardware
> > at hand right now.
>
> Antonio, did you have a chance to try this out yet?
>
> Thanks!
I'll try to set up the environment this week-end, if I fail I'll tell
you; sorry for stalling you.
Ciao,
Antonio
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler
2014-04-06 20:24 ` Dmitry Torokhov
2014-04-06 21:37 ` Antonio Ospite
@ 2014-05-21 9:17 ` Antonio Ospite
1 sibling, 0 replies; 6+ messages in thread
From: Antonio Ospite @ 2014-05-21 9:17 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Alexey Khoroshilov, linux-input, linux-kernel, ldv-project,
Daniel Ribeiro, Ilya Petrov, Antonio Ospite
On Sun, 6 Apr 2014 13:24:36 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Sun, Apr 06, 2014 at 12:54:50AM +0400, Alexey Khoroshilov wrote:
> > pcap_keys_handler() calls ezx_pcap_read() that calls mutex_lock().
> > pcap_keys_handler() is registered as nonthreaded irq handler,
> > that means sleeping function is called in irq handler.
> >
> > The patch makes a switch to threaded irq handling.
> > Compile tested only.
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> > ---
> > drivers/input/misc/pcap_keys.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
> > index cd230365166e..2a10f3a30969 100644
> > --- a/drivers/input/misc/pcap_keys.c
> > +++ b/drivers/input/misc/pcap_keys.c
> > @@ -79,13 +79,15 @@ static int pcap_keys_probe(struct platform_device *pdev)
> > if (err)
> > goto fail_allocate;
> >
> > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > - pcap_keys_handler, 0, "Power key", pcap_keys);
> > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_ONOFF),
> > + NULL, pcap_keys_handler, 0,
> > + "Power key", pcap_keys);
> > if (err)
> > goto fail_register;
> >
> > - err = request_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > - pcap_keys_handler, 0, "Headphone button", pcap_keys);
> > + err = request_threaded_irq(pcap_to_irq(pcap_keys->pcap, PCAP_IRQ_MIC),
> > + NULL, pcap_keys_handler, 0,
> > + "Headphone button", pcap_keys);
>
> So I guess we do need threaded IRQ here, but I do not see the pcap's
> irqchip specifying IRQCHIP_ONESHOT_SAFE so I do not think
> request_threaded_irq() without IRQF_ONESHOT would succeed.
>
> Can someone test the change to be sure?
>
Tested-by: Antonio Ospite <ao2@ao2.it>
I confirm the keys still work fine with the patch applied on a 3.2
kernel. I cannot test on a newer version for now.
Sorry for the delay.
Ciao ciao,
Antonio
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-21 9:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-05 20:54 [PATCH] input: pcap2: avoid calling mutex_lock() in irq handler Alexey Khoroshilov
2014-04-06 20:24 ` Dmitry Torokhov
2014-04-06 21:37 ` Antonio Ospite
2014-05-13 2:14 ` Dmitry Torokhov
2014-05-13 8:13 ` Antonio Ospite
2014-05-21 9:17 ` Antonio Ospite
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).