GIC: Assign correct flow handler type in set_type callback
PATCH 1/1 GIC: Assign correct flow handler type in set_type callback
There are some interrupts that are true edge triggered in nature. If not marked IRQ_PENDING, when disabled, they will be lost.
Use the set_type callback to assign the correct flow type handler for shared peripheral interrupts.
---
This came to light when a edge triggered interrupt was supposed to wakeup the sytem. The flow handler was set to the default handle_level_irq. On the resume path the flow handler was invoked right after the I bit was cleared but before each individual interrupts were enabled. This made the handle_level_irq ignore the interrupt (mask_ack it) and it was lost. handle_edge_irq does the right thing by marking the interrupt as IRQ_PENDING and when the resume code gets to enabling each interrupt this interrupt is resent again.
arch/arm/common/gic.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/common/gic.c +3 -0
@@ -136,6 +136,9 @@ static int gic_set_type(unsigned int irq, unsigned int type)spin_unlock (&irq_controller_lock); +if ((type &IRQ_TYPE_EDGE_RISING ) && gicirq >31 ) +__set_irq_handler_unlocked (irq, handle_edge_irq); +return 0 ; }
Signature · 3 lines
1.7.1 Sent by an employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum.
Quoted 6 lines · Abhijeet Dharmapurikar
There are some interrupts that are true edge triggered in nature. If not marked
IRQ_PENDING, when disabled, they will be lost.Use the
set_typecallback to assign the correct flow type handler for shared peripheral interrupts.
Quoted 6 lines
Signed-off-by Abhijeet Dharmapurikar <[email protected]>---
This came to light when a edge triggered interrupt was supposed to wakeup the sytem. The flow handler was set to the defaulthandle_level_irq. On the resume path the flow handler was invoked right after the I bit was cleared but before each individual interrupts were enabled. This made thehandle_level_irqignore
Why does the flow handler hit when the interrupt is disabled? Have you set IRQF_NOSUSPEND on this interrupt?
Quoted 3 lines
the interrupt (
mask_ackit) and it was lost.handle_edge_irqdoes the right thing by marking the interrupt asIRQ_PENDINGand when the resume code gets to enabling each interrupt this interrupt is resent again.
Quoted 15 lines · Rabin Vincent
Quoted 6 lines · Abhijeet Dharmapurikar
There are some interrupts that are true edge triggered in nature. If not marked
IRQ_PENDING, when disabled, they will be lost.Use the
set_typecallback to assign the correct flow type handler for shared peripheral interrupts.Quoted 6 lines
Signed-off-by Abhijeet Dharmapurikar<[email protected]>---
This came to light when a edge triggered interrupt was supposed to wakeup the sytem. The flow handler was set to the defaulthandle_level_irq. On the resume path the flow handler was invoked right after the I bit was cleared but before each individual interrupts were enabled. This made thehandle_level_irqignore
Quoted 3 lines
Why does the flow handler hit when the interrupt is disabled? Have you set
IRQF_NOSUSPENDon this interrupt?
Since GIC doesnt have disable callback it implements lazy disabling. The interrupt is only marked IRQ_DISABLED in the descriptor but is not masked in the GIC. Hence the interrupt flow handler is hit.
Now that I re-read the code setting IRQF_NO_SUSPEND would fix the issue. But shouldnt set_irq_wake() do something similar?
Do I need to request IRQF_NO_SUSPEND for all the interrupts that could possibly wakeup the system - seems a bit unnecessary. IMO the interrupt should not be disabled if it is marked IRQF_NO_SUPEND || IRQ_WAKEUP is set.
Abhijeet
Quoted 24 lines · Abhijeet Dharmapurikar
Quoted 19 lines · Rabin Vincent
Quoted 7 lines · Abhijeet Dharmapurikar
There are some interrupts that are true edge triggered in nature. If not marked
IRQ_PENDING, when disabled, they will be lost.Use the
set_typecallback to assign the correct flow type handler for shared peripheral interrupts.Signed-off-by Abhijeet Dharmapurikar<[email protected]>Quoted 9 lines
---
This came to light when a edge triggered interrupt was supposed to wakeup the
sytem. The flow handler was set to the defaulthandle_level_irq. On the resume
path the flow handler was invoked right after the I bit was cleared but before
each individual interrupts were enabled. This made thehandle_level_irqignoreQuoted 4 lines
Why does the flow handler hit when the interrupt is disabled? Have you set
IRQF_NOSUSPENDon this interrupt?
Quoted 5 lines
Since GIC doesnt have disable callback it implements lazy disabling. The interrupt is only marked
IRQ_DISABLEDin the descriptor but is not masked in the GIC. Hence the interrupt flow handler is hit.Now that I re-read the code setting
IRQF_NO_SUSPENDwould fix the issue.
Let me correct myself, IRQF_NO_SUSPEND isnt exactly what I want to do. If an interrupt triggers after suspend_device_irqs() is run and before the I bit is set in arch_suspend_disable_irqs() the system will handle the interrupt but will not abort suspend - check_wakeup_irqs() will return 0.
IMO, using handle_edge_irq() for an edge triggered wakeup interrupt would be the right way to address the issue.