All of lore.kernel.org
 help / color / mirror / Atom feed
* Changes in keyboard GPIO driver
@ 2011-01-12  9:41 Philippe Langlais
  2011-01-12  9:41 ` [PATCH] input: replace request_irq by request_any_context_irq " Philippe Langlais
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Langlais @ 2011-01-12  9:41 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, STEricsson_nomadik_linux

This patch is needed to add support for SFH7741 proximity sensor on ux500 platform.
Between ux500 SoC and SFH7741 sensor, we use a GPIO expander (MFD TC35892) which relays the GPIO IRQs.


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

* [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-12  9:41 Changes in keyboard GPIO driver Philippe Langlais
@ 2011-01-12  9:41 ` Philippe Langlais
  2011-01-20  7:53   ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Langlais @ 2011-01-12  9:41 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, STEricsson_nomadik_linux, Philippe Langlais

Signed-off-by: Philippe Langlais <philippe.langlais@stericsson.com>
---
 drivers/input/keyboard/gpio_keys.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 6069abe..eb30063 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
 	struct gpio_keys_button *button = bdata->button;
 	struct input_dev *input = bdata->input;
 	unsigned int type = button->type ?: EV_KEY;
-	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
+	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
 
 	input_event(input, type, button->code, !!state);
 	input_sync(input);
@@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
 	if (!button->can_disable)
 		irqflags |= IRQF_SHARED;
 
-	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
-	if (error) {
+	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
+	if (error < 0) {
 		dev_err(dev, "Unable to claim irq %d; error %d\n",
 			irq, error);
 		goto fail3;
-- 
1.7.3.1


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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-12  9:41 ` [PATCH] input: replace request_irq by request_any_context_irq " Philippe Langlais
@ 2011-01-20  7:53   ` Dmitry Torokhov
  2011-01-20  8:00     ` Trilok Soni
  2011-01-20  9:23     ` Rabin Vincent
  0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2011-01-20  7:53 UTC (permalink / raw)
  To: Philippe Langlais; +Cc: linux-input, STEricsson_nomadik_linux, Trilok Soni

Hi Philippe,

On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
> Signed-off-by: Philippe Langlais <philippe.langlais@stericsson.com>
> ---
>  drivers/input/keyboard/gpio_keys.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 6069abe..eb30063 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
>  	struct gpio_keys_button *button = bdata->button;
>  	struct input_dev *input = bdata->input;
>  	unsigned int type = button->type ?: EV_KEY;
> -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
> +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
>  
>  	input_event(input, type, button->code, !!state);
>  	input_sync(input);
> @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
>  	if (!button->can_disable)
>  		irqflags |= IRQF_SHARED;
>  
> -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> -	if (error) {
> +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> +	if (error < 0) {

No, this it not correct. request_any_context_irq() means that you could
either get a hardirq or a treaded one. However above you are changing to
gpio_get_value_cansleep() which indicates that you can sleep.

You need to either revert to gpio_get_value() or explicitly request
threaded IRQ.

Thanks.

-- 
Dmitry

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20  7:53   ` Dmitry Torokhov
@ 2011-01-20  8:00     ` Trilok Soni
  2011-01-20  8:13       ` Dmitry Torokhov
  2011-01-20  9:23     ` Rabin Vincent
  1 sibling, 1 reply; 10+ messages in thread
From: Trilok Soni @ 2011-01-20  8:00 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Philippe Langlais, linux-input, STEricsson_nomadik_linux

Hi Dmitry,

On 1/20/2011 1:23 PM, Dmitry Torokhov wrote:
> Hi Philippe,
> 
> On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
>> Signed-off-by: Philippe Langlais <philippe.langlais@stericsson.com>
>> ---
>>  drivers/input/keyboard/gpio_keys.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
>> index 6069abe..eb30063 100644
>> --- a/drivers/input/keyboard/gpio_keys.c
>> +++ b/drivers/input/keyboard/gpio_keys.c
>> @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
>>  	struct gpio_keys_button *button = bdata->button;
>>  	struct input_dev *input = bdata->input;
>>  	unsigned int type = button->type ?: EV_KEY;
>> -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
>> +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
>>  
>>  	input_event(input, type, button->code, !!state);
>>  	input_sync(input);
>> @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
>>  	if (!button->can_disable)
>>  		irqflags |= IRQF_SHARED;
>>  
>> -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
>> -	if (error) {
>> +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
>> +	if (error < 0) {
> 
> No, this it not correct. request_any_context_irq() means that you could
> either get a hardirq or a treaded one. However above you are changing to
> gpio_get_value_cansleep() which indicates that you can sleep.
> 
> You need to either revert to gpio_get_value() or explicitly request
> threaded IRQ.

This could be problem. Say, we are doing request_any_context_irq(..) and gpio is over slow-bus,
so we naturally get into the threaded code, and in the thread handler we are calling gpio_get_value(..),
but in this case gpio_get_value could throw a warning that we should call gpio_get_value_cansleep(...)
because sleep attribute is added into the gpiolib hook implementation for these gpios.

Now suppose gpio is memory mapped and we enter into the hardirq and calling sleep variant into the 
handler code will be naturally bad. 

How about checking maysleep explicitly here while using the request_any_context_irq() call though
the semantics of gpiolib framework discourages that. 

---Trilok Soni

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20  8:00     ` Trilok Soni
@ 2011-01-20  8:13       ` Dmitry Torokhov
  2011-01-20  8:56         ` Trilok Soni
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2011-01-20  8:13 UTC (permalink / raw)
  To: Trilok Soni; +Cc: Philippe Langlais, linux-input, STEricsson_nomadik_linux

Hi Trilok,

On Thu, Jan 20, 2011 at 01:30:31PM +0530, Trilok Soni wrote:
> Hi Dmitry,
> 
> On 1/20/2011 1:23 PM, Dmitry Torokhov wrote:
> > Hi Philippe,
> > 
> > On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
> >> Signed-off-by: Philippe Langlais <philippe.langlais@stericsson.com>
> >> ---
> >>  drivers/input/keyboard/gpio_keys.c |    6 +++---
> >>  1 files changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> >> index 6069abe..eb30063 100644
> >> --- a/drivers/input/keyboard/gpio_keys.c
> >> +++ b/drivers/input/keyboard/gpio_keys.c
> >> @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
> >>  	struct gpio_keys_button *button = bdata->button;
> >>  	struct input_dev *input = bdata->input;
> >>  	unsigned int type = button->type ?: EV_KEY;
> >> -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
> >> +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
> >>  
> >>  	input_event(input, type, button->code, !!state);
> >>  	input_sync(input);
> >> @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
> >>  	if (!button->can_disable)
> >>  		irqflags |= IRQF_SHARED;
> >>  
> >> -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> >> -	if (error) {
> >> +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> >> +	if (error < 0) {
> > 
> > No, this it not correct. request_any_context_irq() means that you could
> > either get a hardirq or a treaded one. However above you are changing to
> > gpio_get_value_cansleep() which indicates that you can sleep.
> > 
> > You need to either revert to gpio_get_value() or explicitly request
> > threaded IRQ.
> 
> This could be problem. Say, we are doing request_any_context_irq(..) and gpio is over slow-bus,
> so we naturally get into the threaded code, and in the thread handler we are calling gpio_get_value(..),
> but in this case gpio_get_value could throw a warning that we should call gpio_get_value_cansleep(...)
> because sleep attribute is added into the gpiolib hook implementation for these gpios.
> 
> Now suppose gpio is memory mapped and we enter into the hardirq and calling sleep variant into the 
> handler code will be naturally bad. 
> 
> How about checking maysleep explicitly here while using the request_any_context_irq() call though
> the semantics of gpiolib framework discourages that. 
> 

Any drawbacks for explicitly switching to threaded IRQ and keeping
gpio_get_value_cansleep()? (That was the 2nd option I mentioned BTW).

-- 
Dmitry

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20  8:13       ` Dmitry Torokhov
@ 2011-01-20  8:56         ` Trilok Soni
  0 siblings, 0 replies; 10+ messages in thread
From: Trilok Soni @ 2011-01-20  8:56 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Philippe Langlais, linux-input, STEricsson_nomadik_linux

Hi Dmitry,

On 1/20/2011 1:43 PM, Dmitry Torokhov wrote:
>>>
>>> No, this it not correct. request_any_context_irq() means that you could
>>> either get a hardirq or a treaded one. However above you are changing to
>>> gpio_get_value_cansleep() which indicates that you can sleep.
>>>
>>> You need to either revert to gpio_get_value() or explicitly request
>>> threaded IRQ.
>>
>> This could be problem. Say, we are doing request_any_context_irq(..) and gpio is over slow-bus,
>> so we naturally get into the threaded code, and in the thread handler we are calling gpio_get_value(..),
>> but in this case gpio_get_value could throw a warning that we should call gpio_get_value_cansleep(...)
>> because sleep attribute is added into the gpiolib hook implementation for these gpios.
>>
>> Now suppose gpio is memory mapped and we enter into the hardirq and calling sleep variant into the 
>> handler code will be naturally bad. 
>>
>> How about checking maysleep explicitly here while using the request_any_context_irq() call though
>> the semantics of gpiolib framework discourages that. 
>>
> 
> Any drawbacks for explicitly switching to threaded IRQ and keeping
> gpio_get_value_cansleep()? (That was the 2nd option I mentioned BTW).
> 

Only drawback is that you get "dedicated thread" in case the irqs are not chained handler. In worst-case
it would introduce the latencies otherwise fine.

---Trilok Soni

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20  7:53   ` Dmitry Torokhov
  2011-01-20  8:00     ` Trilok Soni
@ 2011-01-20  9:23     ` Rabin Vincent
  2011-01-20 10:04       ` Dmitry Torokhov
  1 sibling, 1 reply; 10+ messages in thread
From: Rabin Vincent @ 2011-01-20  9:23 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Philippe LANGLAIS, linux-input, STEricsson_nomadik_linux, Trilok Soni

On Thu, Jan 20, 2011 at 08:53:48 +0100, Dmitry Torokhov wrote:
> On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
> > diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> > index 6069abe..eb30063 100644
> > --- a/drivers/input/keyboard/gpio_keys.c
> > +++ b/drivers/input/keyboard/gpio_keys.c
> > @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
> >  	struct gpio_keys_button *button = bdata->button;
> >  	struct input_dev *input = bdata->input;
> >  	unsigned int type = button->type ?: EV_KEY;
> > -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
> > +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
> >  
> >  	input_event(input, type, button->code, !!state);
> >  	input_sync(input);
> > @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
> >  	if (!button->can_disable)
> >  		irqflags |= IRQF_SHARED;
> >  
> > -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> > -	if (error) {
> > +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> > +	if (error < 0) {
> 
> No, this it not correct. request_any_context_irq() means that you could
> either get a hardirq or a treaded one. However above you are changing to
> gpio_get_value_cansleep() which indicates that you can sleep.

Note that gpio_get_value_cansleep() is not being called from the interrupt
handler (threaded or not), but from a work queue.

Rabin


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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20  9:23     ` Rabin Vincent
@ 2011-01-20 10:04       ` Dmitry Torokhov
  2011-01-20 12:14         ` Philippe Langlais
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2011-01-20 10:04 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Philippe LANGLAIS, linux-input, STEricsson_nomadik_linux, Trilok Soni

On Thu, Jan 20, 2011 at 02:53:30PM +0530, Rabin Vincent wrote:
> On Thu, Jan 20, 2011 at 08:53:48 +0100, Dmitry Torokhov wrote:
> > On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
> > > diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> > > index 6069abe..eb30063 100644
> > > --- a/drivers/input/keyboard/gpio_keys.c
> > > +++ b/drivers/input/keyboard/gpio_keys.c
> > > @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
> > >  	struct gpio_keys_button *button = bdata->button;
> > >  	struct input_dev *input = bdata->input;
> > >  	unsigned int type = button->type ?: EV_KEY;
> > > -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
> > > +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
> > >  
> > >  	input_event(input, type, button->code, !!state);
> > >  	input_sync(input);
> > > @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
> > >  	if (!button->can_disable)
> > >  		irqflags |= IRQF_SHARED;
> > >  
> > > -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> > > -	if (error) {
> > > +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
> > > +	if (error < 0) {
> > 
> > No, this it not correct. request_any_context_irq() means that you could
> > either get a hardirq or a treaded one. However above you are changing to
> > gpio_get_value_cansleep() which indicates that you can sleep.
> 
> Note that gpio_get_value_cansleep() is not being called from the interrupt
> handler (threaded or not), but from a work queue.
> 

Ah, then everything is good, sorry about the noise.

-- 
Dmitry

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20 10:04       ` Dmitry Torokhov
@ 2011-01-20 12:14         ` Philippe Langlais
  2011-01-21  7:10           ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Langlais @ 2011-01-20 12:14 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Rabin VINCENT, linux-input, STEricsson_nomadik_linux,
	Trilok Soni, lee.jones

Dmitry,

Sorry, I arrive after the war, thanks Rabin for your answer.
When can I hope this patch merged in kernel?

Philippe

On 01/20/11 11:04, Dmitry Torokhov wrote:
> On Thu, Jan 20, 2011 at 02:53:30PM +0530, Rabin Vincent wrote:
>> On Thu, Jan 20, 2011 at 08:53:48 +0100, Dmitry Torokhov wrote:
>>> On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
>>>> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
>>>> index 6069abe..eb30063 100644
>>>> --- a/drivers/input/keyboard/gpio_keys.c
>>>> +++ b/drivers/input/keyboard/gpio_keys.c
>>>> @@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
>>>>   	struct gpio_keys_button *button = bdata->button;
>>>>   	struct input_dev *input = bdata->input;
>>>>   	unsigned int type = button->type ?: EV_KEY;
>>>> -	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
>>>> +	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
>>>>
>>>>   	input_event(input, type, button->code, !!state);
>>>>   	input_sync(input);
>>>> @@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
>>>>   	if (!button->can_disable)
>>>>   		irqflags |= IRQF_SHARED;
>>>>
>>>> -	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
>>>> -	if (error) {
>>>> +	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
>>>> +	if (error<  0) {
>>> No, this it not correct. request_any_context_irq() means that you could
>>> either get a hardirq or a treaded one. However above you are changing to
>>> gpio_get_value_cansleep() which indicates that you can sleep.
>> Note that gpio_get_value_cansleep() is not being called from the interrupt
>> handler (threaded or not), but from a work queue.
>>
> Ah, then everything is good, sorry about the noise.
>

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

* Re: [PATCH] input: replace request_irq by request_any_context_irq in keyboard GPIO driver
  2011-01-20 12:14         ` Philippe Langlais
@ 2011-01-21  7:10           ` Dmitry Torokhov
  0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2011-01-21  7:10 UTC (permalink / raw)
  To: Philippe Langlais
  Cc: Rabin VINCENT, linux-input, STEricsson_nomadik_linux,
	Trilok Soni, lee.jones

On Thu, Jan 20, 2011 at 01:14:50PM +0100, Philippe Langlais wrote:
> Dmitry,
> 
> Sorry, I arrive after the war, thanks Rabin for your answer.
> When can I hope this patch merged in kernel?

Applied and will be included in the next pull request.

Thanks!

-- 
Dmitry

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

end of thread, other threads:[~2011-01-21  7:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-12  9:41 Changes in keyboard GPIO driver Philippe Langlais
2011-01-12  9:41 ` [PATCH] input: replace request_irq by request_any_context_irq " Philippe Langlais
2011-01-20  7:53   ` Dmitry Torokhov
2011-01-20  8:00     ` Trilok Soni
2011-01-20  8:13       ` Dmitry Torokhov
2011-01-20  8:56         ` Trilok Soni
2011-01-20  9:23     ` Rabin Vincent
2011-01-20 10:04       ` Dmitry Torokhov
2011-01-20 12:14         ` Philippe Langlais
2011-01-21  7:10           ` Dmitry Torokhov

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.