Skip to contentSkip to conversation

gpio irq problem on Zynq

Xenomai Gwenhael Goavec-Merou 2 participants 3 messages Sep 20, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

I use a Zynq with the latest Xenomai/Ipipe version and I've problems when using GPIO interrupts. Currently, my tests are only in the Linux domain.

1/ When using gpiolib the system freeze after gpio's configuration through /sys/class/gpio/xxx . I suspect the corresponding IRQ not masked or not acquitted.
2/ With a driver the ISR is never called but the system is not freezed.

I've looked on gpio-zynq.c but I've no idea about the reason why the system has these wrong behaviour.

Thank you for all comment/advises about my issue.

Gwenhael Goavec-Merou

#1 lore raw
Quoted 10 lines · Gwenhael Goavec-Merou

Hi,

I use a Zynq with the latest Xenomai/Ipipe version and I've problems> when using GPIO interrupts. Currently, my tests are only in the Linux domain.

1/ When using gpiolib the system freeze after gpio's configuration through /sys/class/gpio/xxx . I suspect the corresponding IRQ not masked or not acquitted.
2/ With a driver the ISR is never called but the system is not freezed.

Quoted 5 lines

I've looked on gpio-zynq.c but I've no idea about the reason why the system has these wrong behaviour.

Thank you for all comment/advises about my issue.

Assuming kernel 4.9.x, maybe this helps:

drivers/gpio/gpio-zynq.c +3 -2
index 1675284..47c1a9a 100644
@@ -503,10 +503,12 @@ static void zynq_gpio_hold_irq(struct irq_data *irq_data)
 
 	device_pin_num = irq_data->hwirq;
 	zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio);
+	raw_spin_lock(&zynq_gpio_lock);
 	writel_relaxed(BIT(bank_pin_num),
 		       gpio->base_addr + ZYNQ_GPIO_INTDIS_OFFSET(bank_num));
 	writel_relaxed(BIT(bank_pin_num),
 		       gpio->base_addr + ZYNQ_GPIO_INTSTS_OFFSET(bank_num));
+	raw_spin_unlock(&zynq_gpio_lock);
 }
 
 static void zynq_gpio_release_irq(struct irq_data *irq_data)
@@ -570,7 +572,7 @@ static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
 		unsigned int gpio_irq;
 
 		gpio_irq = irq_find_mapping(irqdomain, offset + bank_offset);
-		generic_handle_irq(gpio_irq);
+		ipipe_handle_demuxed_irq(gpio_irq);
 	}
 }
-- 

Philippe.

#2 lore raw
Quoted 13 lines · On Wed, 20 Sep 2017 11:07:33 +0200 Philippe Gerum <[email protected]> wrote:
Quoted 12 lines · Gwenhael Goavec-Merou

Hi,

I use a Zynq with the latest Xenomai/Ipipe version and I've problems> when using GPIO interrupts. Currently, my tests are only problems> in the Linux domain.

1/ When using gpiolib the system freeze after gpio's configuration through /sys/class/gpio/xxx . I suspect the corresponding IRQ not masked or not acquitted.
2/ With a driver the ISR is never called but the system is not freezed.

Quoted 7 lines
Quoted 5 lines

I've looked on gpio-zynq.c but I've no idea about the reason why the system has these wrong behaviour.

Thank you for all comment/advises about my issue.

Assuming kernel 4.9.x, maybe this helps:

Yes, sorry it's a 4.9.38

Quoted 31 lines
drivers/gpio/gpio-zynq.c +2 -0
index 1675284..47c1a9a 100644
@@ -503,10 +503,12 @@ static void zynq_gpio_hold_irq(struct irq_data
 *irq_data) 
 	device_pin_num = irq_data->hwirq;
 	zynq_gpio_get_bank_pin(device_pin_num, &bank_num,
 &bank_pin_num, gpio);
+	raw_spin_lock(&zynq_gpio_lock);
 	writel_relaxed(BIT(bank_pin_num),
 		       gpio->base_addr +
 ZYNQ_GPIO_INTDIS_OFFSET(bank_num)); writel_relaxed(BIT(bank_pin_num),
 		       gpio->base_addr +
 ZYNQ_GPIO_INTSTS_OFFSET(bank_num));
+	raw_spin_unlock(&zynq_gpio_lock);
 }

static void zynq_gpio_release_irq(struct irq_data *irq_data)

drivers/gpio/gpio-zynq.c +1 -1
@@ -570,7 +572,7 @@ static void zynq_gpio_handle_bank_irq(struct
 zynq_gpio *gpio, unsigned int gpio_irq;
 
 		gpio_irq = irq_find_mapping(irqdomain, offset +
 bank_offset);
-		generic_handle_irq(gpio_irq);
+		ipipe_handle_demuxed_irq(gpio_irq);
 	}
 }
Signature · 1 line
Philippe.

This modification fix my issue.

Thanks

Gwenhael