Re: [PATCH v1] gpio: dwapb: mask/unmask IRQ when disable/enable it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2020/11/30 19:22, Andy Shevchenko wrote:
On Mon, Nov 30, 2020 at 05:36:19PM +0800, Luo Jiaxing wrote:
The mask and unmask registers are not configured in dwapb_irq_enable() and
dwapb_irq_disable(). In the following situations, the IRQ will be masked by
default after the IRQ is enabled:

mask IRQ -> disable IRQ -> enable IRQ

In this case, the IRQ status of GPIO controller is inconsistent with it's
irq_data too. For example, in __irq_enable(), IRQD_IRQ_DISABLED and
IRQD_IRQ_MASKED are both clear, but GPIO controller do not perform unmask.
Sounds a bit like a papering over the issue which is slightly different.
Can you elaborate more, why ->irq_mask() / ->irq_unmask() are not being called?


Sure, The basic software invoking process is as follows:

Release IRQ:
free_irq() -> __free_irq() -> irq_shutdown() ->__irq_disable()

Disable IRQ:
disable_irq() -> __disable_irq_nosync() -> __disable_irq -> irq_disable -> __irq_disable()

As shown before, both will call __irq_disable(). The code of it is as follows:

if (irqd_irq_disabled(&desc->irq_data)) {
    if (mask)
        mask_irq(desc);

} else {
        irq_state_set_disabled(desc);
            if (desc->irq_data.chip->irq_disable) {
desc->irq_data.chip->irq_disable(&desc->irq_data);
                irq_state_set_masked(desc);
            } else if (mask) {
                mask_irq(desc);
    }
}

Because gpio-dwapb.c provides the hook function of irq_disable, __irq_disable() will directly calls chip->irq_disable() instead of mask_irq().

For irq_enable(), it's similar and the code is as follows:

if (!irqd_irq_disabled(&desc->irq_data)) {
    unmask_irq(desc);
} else {
    irq_state_clr_disabled(desc);
    if (desc->irq_data.chip->irq_enable) {
desc->irq_data.chip->irq_enable(&desc->irq_data);
        irq_state_clr_masked(desc);
    } else {
        unmask_irq(desc);
    }
}

Similarly, because gpio-dwapb.c provides the hook function of irq_enable, irq_enable() will directly calls chip->irq_enable() but does not call unmask_irq().


Therefore, the current handle is as follows:

API of IRQ:        |   mask_irq()             | disable_irq()            |    enable_irq()

gpio-dwapb.c:  |   chip->irq_mask()   | chip->irq_diable()   |    chip->irq_enable()

I do not know why irq_enable() only calls chip->irq_enable(). However, the code shows that irq_enable() clears the disable and masked flags in the irq_data state.

Therefore, for gpio-dwapb.c, I thinks ->irq_enable also needs to clear the disable and masked flags in the hardware register.







[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux