From: Thomas Gleixner <tglx@linutronix.de>
To: xiongxin <xiongxin@kylinos.cn>,
jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: linux-input@vger.kernel.org, stable@vger.kernel.org,
Riwen Lu <luriwen@kylinos.cn>,
hoan@os.amperecomputing.com, fancer.lancer@gmail.com,
linus.walleij@linaro.org, brgl@bgdev.pl, andy@kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irq: Resolve that mask_irq/unmask_irq may not be called in pairs
Date: Wed, 13 Dec 2023 15:59:31 +0100 [thread overview]
Message-ID: <875y12p2r0.ffs@tglx> (raw)
In-Reply-To: <bf4004bf-4868-4953-8d8e-0c0e03be673e@kylinos.cn>
On Wed, Dec 13 2023 at 10:29, xiongxin wrote:
> 在 2023/12/12 23:17, Thomas Gleixner 写道:
> Sorry, the previous reply may not have clarified the BUG process. I
> re-debugged and confirmed it yesterday. The current BUG execution
> sequence is described as follows:
It's the sequence how this works and it works correctly.
Just because it does not work on your machine it does not mean that this
is incorrect and a BUG.
You are trying to fix a symptom and thereby violating guarantees of the
core code.
> That is, there is a time between the 1:handle_level_irq() and
> 3:irq_thread_fn() calls for the 2:disable_irq() call to acquire the lock
> and then implement the irq_state_set_disabled() operation. When finally
> call irq_thread_fn()->irq_finalize_oneshot(), it cannot enter the
> unmask_thread_irq() process.
Correct, because the interrupt has been DISABLED in the mean time.
> In this case, the gpio irq_chip irq_mask()/irq_unmask() callback pairs
> are not called in pairs, so I think this is a BUG, but not necessarily
> fixed from the irq core code layer.
No. It is _NOT_ a BUG. unmask() is not allowed to be invoked when the
interrupt is DISABLED. That's the last time I'm going to tell you that.
Only enable_irq() can undo the effect of disable_irq(), period.
> Next, when the gpio controller driver calls the suspend/resume process,
> it is as follows:
>
> suspend process:
> dwapb_gpio_suspend()
> ctx->int_mask = dwapb_read(gpio, GPIO_INTMASK);
>
> resume process:
> dwapb_gpio_resume()
> dwapb_write(gpio, GPIO_INTMASK, ctx->int_mask);
Did you actually look at the sequence I gave you?
Suspend:
i2c_hid_core_suspend()
disable_irq(); <- Marks it disabled and eventually
masks it.
gpio_irq_suspend()
save_registers(); <- Saves masked interrupt
Resume:
gpio_irq_resume()
restore_registers(); <- Restores masked interrupt
i2c_hid_core_resume()
enable_irq(); <- Unmasks interrupt and removes the
disabled marker
Have you verified that this order of invocations is what happens on
your machine?
Thanks,
tglx
next prev parent reply other threads:[~2023-12-13 14:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 1:40 [PATCH] irq: Resolve that mask_irq/unmask_irq may not be called in pairs xiongxin
2023-12-08 13:52 ` Thomas Gleixner
2023-12-11 3:10 ` xiongxin
2023-12-12 15:17 ` Thomas Gleixner
2023-12-13 2:29 ` xiongxin
2023-12-13 14:59 ` Thomas Gleixner [this message]
2023-12-14 1:54 ` xiongxin
2023-12-14 10:06 ` Serge Semin
2023-12-14 16:11 ` Andy Shevchenko
2023-12-15 2:18 ` xiongxin
2023-12-14 10:13 ` Thomas Gleixner
2023-12-12 16:57 ` Jiri Kosina
[not found] ` <1702429454313015.485.seg@mailgw>
2023-12-13 2:35 ` xiongxin
-- strict thread matches above, loose matches on Subject: below --
2023-12-07 1:31 xiongxin
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=875y12p2r0.ffs@tglx \
--to=tglx@linutronix.de \
--cc=andy@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=brgl@bgdev.pl \
--cc=fancer.lancer@gmail.com \
--cc=hoan@os.amperecomputing.com \
--cc=jikos@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luriwen@kylinos.cn \
--cc=stable@vger.kernel.org \
--cc=xiongxin@kylinos.cn \
/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