From: luojiaxing <luojiaxing@huawei.com>
To: Serge Semin <fancer.lancer@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Jason Cooper <jason@lakedaemon.net>,
Marc Zyngier <maz@kernel.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
<bgolaszewski@baylibre.com>, <linus.walleij@linaro.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>
Subject: Re: [PATCH v1] gpio: dwapb: mask/unmask IRQ when disable/enable it
Date: Mon, 7 Dec 2020 20:44:55 +0800 [thread overview]
Message-ID: <a25a0eaf-f4ce-b2db-dea2-667fac62985f@huawei.com> (raw)
In-Reply-To: <20201205221522.ifjravnir5bzmjff@mobilestation>
On 2020/12/6 6:15, Serge Semin wrote:
> On Tue, Dec 01, 2020 at 04:59:21PM +0800, luojiaxing wrote:
>> 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.
>>
> Hmm, that sounds like a problem, but the explanation is a bit unclear
> to me. AFAICS you are saying that the only callbacks which are
> called during the IRQ request/release are the irq_enable(), right?
Yes, but one point needs to be clarified, for IRQ requests, it calls
irq_enable(); for IRQ release, it calls irq_disable().
Actually I am thinking that why only irq_enable()/irq_disable() is
called since the mask and enable flags of irq_data are both set.
Does IRQ subsystem expect irq_enable to set both mask and enable? If we
didn't do that, the state machine of the software is different from
hardware, at least for mask bit.
> If
> so then the only reason why we haven't got a problem reported due to
> that so far is that the IRQs actually unmasked by default.
yes, I think so, Common drivers do not mask the IRQ before releasing it.
But that's possible.
>
> In anyway I'd suggest to join someone from the kernel IRQs-related
> subsystem to this discussion to ask their opinion whether the IRQs
> setup procedure is supposed to work like you say and the irq_enable
> shall actually also unmask IRQs.
>
> Thomas, Jason, Mark, could you give us your comment about the issue?
>
> -Sergey
>
>>
>>
> .
>
next prev parent reply other threads:[~2020-12-07 12:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 9:36 [PATCH v1] gpio: dwapb: mask/unmask IRQ when disable/enable it Luo Jiaxing
2020-11-30 11:22 ` Andy Shevchenko
2020-12-01 8:59 ` luojiaxing
2020-12-05 22:15 ` Serge Semin
2020-12-06 15:02 ` Linus Walleij
2020-12-06 18:50 ` Marc Zyngier
2020-12-07 13:10 ` luojiaxing
2021-01-06 10:24 ` Bartosz Golaszewski
[not found] ` <CAHp75VcFo2hc1kjP9jLxmCdN79rD2R4vCw2P8UssbWe2v4zwcw@mail.gmail.com>
2021-01-07 12:20 ` Serge Semin
2020-12-07 13:04 ` luojiaxing
2020-12-07 12:44 ` luojiaxing [this message]
2020-12-05 21:58 ` Linus Walleij
2023-12-15 8:09 ` Thomas Gleixner
2023-12-15 10:24 ` Serge Semin
2023-12-15 10:56 ` Thomas Gleixner
2023-12-15 12:57 ` Serge Semin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a25a0eaf-f4ce-b2db-dea2-667fac62985f@huawei.com \
--to=luojiaxing@huawei.com \
--cc=andy.shevchenko@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=fancer.lancer@gmail.com \
--cc=jason@lakedaemon.net \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).