Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: qcom: Move clearing pending IRQ to .irq_request_resources callback

When GPIOs that are routed to PDC are used as output they can still latch
the IRQ pending at GIC. As a result the spurious IRQ was handled when the
client driver change the direction to input to starts using it as IRQ.

Currently such erroneous latched IRQ are cleared with .irq_enable callback
however if the driver continue to use GPIO as interrupt and invokes
disable_irq() followed by enable_irq() then everytime during enable_irq()
previously latched interrupt gets cleared.

This can make edge IRQs not seen after enable_irq() if they had arrived
after the driver has invoked disable_irq() and were pending at GIC.

Move clearing erroneous IRQ to .irq_request_resources callback as this is
the place where GPIO direction is changed as input and its locked as IRQ.

While at this add a missing check to invoke msm_gpio_irq_clear_unmask()
from .irq_enable callback only when GPIO is not routed to PDC.

Fixes: e35a6ae0eb3a ("pinctrl/msm: Setup GPIO chip in hierarchy")
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
Link: https://lore.kernel.org/r/1604561884-10166-1-git-send-email-mkshah@codeaurora.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Maulik Shah and committed by
Linus Walleij
71266d9d c64a6a0d

+20 -14
+20 -14
drivers/pinctrl/qcom/pinctrl-msm.c
··· 815 815 816 816 static void msm_gpio_irq_enable(struct irq_data *d) 817 817 { 818 - /* 819 - * Clear the interrupt that may be pending before we enable 820 - * the line. 821 - * This is especially a problem with the GPIOs routed to the 822 - * PDC. These GPIOs are direct-connect interrupts to the GIC. 823 - * Disabling the interrupt line at the PDC does not prevent 824 - * the interrupt from being latched at the GIC. The state at 825 - * GIC needs to be cleared before enabling. 826 - */ 827 - if (d->parent_data) { 828 - irq_chip_set_parent_state(d, IRQCHIP_STATE_PENDING, 0); 829 - irq_chip_enable_parent(d); 830 - } 818 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 819 + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); 831 820 832 - msm_gpio_irq_clear_unmask(d, true); 821 + if (d->parent_data) 822 + irq_chip_enable_parent(d); 823 + 824 + if (!test_bit(d->hwirq, pctrl->skip_wake_irqs)) 825 + msm_gpio_irq_clear_unmask(d, true); 833 826 } 834 827 835 828 static void msm_gpio_irq_disable(struct irq_data *d) ··· 1097 1104 ret = -EINVAL; 1098 1105 goto out; 1099 1106 } 1107 + 1108 + /* 1109 + * Clear the interrupt that may be pending before we enable 1110 + * the line. 1111 + * This is especially a problem with the GPIOs routed to the 1112 + * PDC. These GPIOs are direct-connect interrupts to the GIC. 1113 + * Disabling the interrupt line at the PDC does not prevent 1114 + * the interrupt from being latched at the GIC. The state at 1115 + * GIC needs to be cleared before enabling. 1116 + */ 1117 + if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs)) 1118 + irq_chip_set_parent_state(d, IRQCHIP_STATE_PENDING, 0); 1119 + 1100 1120 return 0; 1101 1121 out: 1102 1122 module_put(gc->owner);