public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: xiongxin <xiongxin@kylinos.cn>,
	jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: linux-input@vger.kernel.org, xiongxin <xiongxin@kylinos.cn>,
	stable@vger.kernel.org, Riwen Lu <luriwen@kylinos.cn>
Subject: Re: [PATCH] irq: Resolve that mask_irq/unmask_irq may not be called in pairs
Date: Fri, 08 Dec 2023 14:52:14 +0100	[thread overview]
Message-ID: <87ttosssxd.ffs@tglx> (raw)
In-Reply-To: <20231207014003.12919-1-xiongxin@kylinos.cn>

On Thu, Dec 07 2023 at 09:40, xiongxin@kylinos.cn wrote:
> When an interrupt controller uses a function such as handle_level_irq()
> as an interrupt handler and the controller implements the irq_disable()
> callback, the following scenario will appear in the i2c-hid driver in
> the sleep scenario:
>
> in the sleep flow, while the user is still triggering the i2c-hid
> interrupt, we get the following function call:
>
>   handle_level_irq()
>     -> mask_ack_irq()
>       -> mask_irq()
> 				i2c_hid_core_suspend()
> 				  -> disable_irq()
> 				    -> __irq_disable()
> 				      -> irq_state_set_disabled()
> 				      -> irq_state_set_masked()
>
>   irq_thread_fn()
>     -> irq_finalize_oneshot()
>       -> if (!desc->threads_oneshot && !irqd_irq_disabled() &&
> 	     irqd_irq_masked())
>       	 	unmask_threaded_irq()
> 		  -> unmask_irq()
>
> That is, when __irq_disable() is called between mask_irq() and
> irq_finalize_oneshot(), the code in irq_finalize_oneshot() will cause
> the !irqd_irq_disabled() fails to enter the unmask_irq() branch, which
> causes mask_irq/unmask_irq to be called unpaired and the i2c-hid
> interrupt to be masked.
>
> Since mask_irq/unmask_irq and irq_disabled() belong to two different
> hardware registers or policies, the !irqd_irq_disabled() assertion may
> not be used to determine whether unmask_irq() needs to be called.

No. That's fundamentally wrong.

Disabled interrupts are disabled and can only be reenabled by the
corresponding enable call. The existing code is entirely correct.

What you are trying to do is unmasking a disabled interrupt, which
results in inconsistent state.

Which interrupt chip is involved here?

Thanks,

        tglx


  reply	other threads:[~2023-12-08 13:52 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 [this message]
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
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=87ttosssxd.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@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