Skip to contentSkip to conversation

irqchip: gic: correct gic_set_type trigger acceptance criteria

PATCH In review Feng Kan 2 participants 2 messages Aug 21, 2014 – Aug 22, 2014

Subsystems (2)
lore
Share & tools
lore

Feng Kan

author
#0 lore raw

PATCH 1/1 irqchip: gic: correct gic_set_type trigger acceptance criteria

GIC is designed to support two types of trigger mechanism. Either active level high or edge rising.

static int gic_set_type(struct irq_data *d, unsigned int type)

{
	...
        if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
                return -EINVAL;

However, this cause problem with requesting driver uses combo selections to tie down trigger mechanism. In below case gpio_keys_setup_key tries to use either rising or falling edge trigger, but accidently cause a false positive in the gic code.

static int gpio_keys_setup_key(struct platform_device *pdev,

{
                irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;

This patch fixes this problem by filter the selection type first.

---
 drivers/irqchip/irq-gic.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic.c +1 -0
index c31eea4..bea167e 100644
@@ -194,6 +194,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
 	if (gicirq < 16)
 		return -EINVAL;
 
+	type &= IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING;
 	if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
 		return -EINVAL;
 
Signature · 1 line
1.9.1
#1 lore raw

Hi Fen,

Quoted 14 lines · Feng Kan

GIC is designed to support two types of trigger mechanism. Either active level high or edge rising.

static int gic_set_type(struct irq_data *d, unsigned int type)

{
	...
        if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
                return -EINVAL;

However, this cause problem with requesting driver uses combo selections to tie down trigger mechanism. In below case gpio_keys_setup_key tries to use either rising or falling edge trigger, but accidently cause a false positive in the gic code.

Quoted 5 lines

static int gpio_keys_setup_key(struct platform_device *pdev,

{
                irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;

This patch fixes this problem by filter the selection type first.

I think this is the wrong thing to do. The semantic of the driver is to receive an interrupt on both key-press and key-release. It needs both events to function correctly.

While your patch enables the driver, it also only give it one of the two expected events, and things will break. You should fix the gpio-keys driver to only request one of the possible events (possibly detect when it is failing to configure the interrupt).

Thanks,

	M.
Quoted 19 lines
---
 drivers/irqchip/irq-gic.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic.c +1 -0
index c31eea4..bea167e 100644
@@ -194,6 +194,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
 	if (gicirq < 16)
 		return -EINVAL;
 
+	type &= IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING;
 	if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
 		return -EINVAL;
 
Signature · 1 line
Jazz is not dead. It just smells funny...