From: Philippe Langlais <hidden> Date: 2011-01-12 10:04:08
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.
@@ -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
@@ -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.
@@ -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
From: Trilok Soni <hidden> Date: 2011-01-20 08:56:43
Hi Dmitry,
On 1/20/2011 1:43 PM, Dmitry Torokhov wrote:
quoted
quoted
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.
@@ -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
@@ -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
From: Philippe Langlais <hidden> Date: 2011-01-20 12:17:20
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:
quoted
On Thu, Jan 20, 2011 at 08:53:48 +0100, Dmitry Torokhov wrote:
quoted
On Wed, Jan 12, 2011 at 10:41:32AM +0100, Philippe Langlais wrote:
@@ -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.