Skip to content

Commit 71266d9

Browse files
mkshahclinusw
authored andcommitted
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: e35a6ae ("pinctrl/msm: Setup GPIO chip in hierarchy") Signed-off-by: Maulik Shah <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent c64a6a0 commit 71266d9

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -815,21 +815,14 @@ static void msm_gpio_irq_clear_unmask(struct irq_data *d, bool status_clear)
815815

816816
static void msm_gpio_irq_enable(struct irq_data *d)
817817
{
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);
818+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
819+
struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
820+
821+
if (d->parent_data)
829822
irq_chip_enable_parent(d);
830-
}
831823

832-
msm_gpio_irq_clear_unmask(d, true);
824+
if (!test_bit(d->hwirq, pctrl->skip_wake_irqs))
825+
msm_gpio_irq_clear_unmask(d, true);
833826
}
834827

835828
static void msm_gpio_irq_disable(struct irq_data *d)
@@ -1104,6 +1097,19 @@ static int msm_gpio_irq_reqres(struct irq_data *d)
11041097
ret = -EINVAL;
11051098
goto out;
11061099
}
1100+
1101+
/*
1102+
* Clear the interrupt that may be pending before we enable
1103+
* the line.
1104+
* This is especially a problem with the GPIOs routed to the
1105+
* PDC. These GPIOs are direct-connect interrupts to the GIC.
1106+
* Disabling the interrupt line at the PDC does not prevent
1107+
* the interrupt from being latched at the GIC. The state at
1108+
* GIC needs to be cleared before enabling.
1109+
*/
1110+
if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs))
1111+
irq_chip_set_parent_state(d, IRQCHIP_STATE_PENDING, 0);
1112+
11071113
return 0;
11081114
out:
11091115
module_put(gc->owner);

0 commit comments

Comments
 (0)