Skip to content

Commit 4079d35

Browse files
dianderslinusw
authored andcommitted
pinctrl: qcom: No need to read-modify-write the interrupt status
When the Qualcomm pinctrl driver wants to Ack an interrupt, it does a read-modify-write on the interrupt status register. On some SoCs it makes sure that the status bit is 1 to "Ack" and on others it makes sure that the bit is 0 to "Ack". Presumably the first type of interrupt controller is a "write 1 to clear" type register and the second just let you directly set the interrupt status register. As far as I can tell from scanning structure definitions, the interrupt status bit is always in a register by itself. Thus with both types of interrupt controllers it is safe to "Ack" interrupts without doing a read-modify-write. We can do a simple write. It should be noted that if the interrupt status bit _was_ ever in a register with other things (like maybe status bits for other GPIOs): a) For "write 1 clear" type controllers then read-modify-write would be totally wrong because we'd accidentally end up clearing interrupts we weren't looking at. b) For "direct set" type controllers then read-modify-write would also be wrong because someone setting one of the other bits in the register might accidentally clear (or set) our interrupt. I say this simply to show that the current read-modify-write doesn't provide any sort of "future proofing" of the code. In fact (for "write 1 clear" controllers) the new code is slightly more "future proof" since it would allow more than one interrupt status bits to share a register. NOTE: this code fixes no bugs--it simply avoids an extra register read. Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Maulik Shah <[email protected]> Tested-by: Maulik Shah <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/20210114191601.v7.2.I3635de080604e1feda770591c5563bd6e63dd39d@changeid Signed-off-by: Linus Walleij <[email protected]>
1 parent a82e537 commit 4079d35

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -791,16 +791,13 @@ static void msm_gpio_irq_clear_unmask(struct irq_data *d, bool status_clear)
791791

792792
raw_spin_lock_irqsave(&pctrl->lock, flags);
793793

794-
if (status_clear) {
795-
/*
796-
* clear the interrupt status bit before unmask to avoid
797-
* any erroneous interrupts that would have got latched
798-
* when the interrupt is not in use.
799-
*/
800-
val = msm_readl_intr_status(pctrl, g);
801-
val &= ~BIT(g->intr_status_bit);
802-
msm_writel_intr_status(val, pctrl, g);
803-
}
794+
/*
795+
* clear the interrupt status bit before unmask to avoid
796+
* any erroneous interrupts that would have got latched
797+
* when the interrupt is not in use.
798+
*/
799+
if (status_clear)
800+
msm_writel_intr_status(0, pctrl, g);
804801

805802
val = msm_readl_intr_cfg(pctrl, g);
806803
val |= BIT(g->intr_raw_status_bit);
@@ -905,11 +902,7 @@ static void msm_gpio_irq_ack(struct irq_data *d)
905902

906903
raw_spin_lock_irqsave(&pctrl->lock, flags);
907904

908-
val = msm_readl_intr_status(pctrl, g);
909-
if (g->intr_ack_high)
910-
val |= BIT(g->intr_status_bit);
911-
else
912-
val &= ~BIT(g->intr_status_bit);
905+
val = g->intr_ack_high ? BIT(g->intr_status_bit) : 0;
913906
msm_writel_intr_status(val, pctrl, g);
914907

915908
if (test_bit(d->hwirq, pctrl->dual_edge_irqs))

0 commit comments

Comments
 (0)