linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hector Martin <marcan@marcan.st>
To: Sven Peter <sven@svenpeter.dev>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqchip/apple-aic: fix irq_disable from within irq handlers
Date: Wed, 18 Aug 2021 20:35:04 +0900	[thread overview]
Message-ID: <9b2805ec-e5b4-bb1b-abee-0bff7e3dbf24@marcan.st> (raw)
In-Reply-To: <20210812100942.17206-1-sven@svenpeter.dev>

*Puts on kernel maintainer hat again*

Sorry for the delay. I've been spending too much time on hardware RE 
recently...

On 12/08/2021 19.09, Sven Peter wrote:
> When disable_irq_nosync for an interrupt is called from within its
> interrupt handler, this interrupt is only marked as disabled with the
> intention to mask it when it triggers again.
> The AIC hardware however automatically masks the interrupt when it is read.
> aic_irq_eoi then unmasks it again if it's not disabled *and* not masked.
> This results in a state mismatch between the hardware state and the
> state kept in irq_data: The hardware interrupt is masked but
> IRQD_IRQ_MASKED is not set. Any further calls to unmask_irq will directly
> return and the interrupt can never be enabled again.
> 
> Fix this by keeping the hardware and irq_data state in sync by unmasking in
> aic_irq_eoi if and only if the irq_data state also assumes the interrupt to
> be unmasked.
> 
> Fixes: 76cde2639411 ("irqchip/apple-aic: Add support for the Apple Interrupt Controller")
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
>   drivers/irqchip/irq-apple-aic.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c
> index b8c06bd8659e..6fc145aacaf0 100644
> --- a/drivers/irqchip/irq-apple-aic.c
> +++ b/drivers/irqchip/irq-apple-aic.c
> @@ -226,7 +226,7 @@ static void aic_irq_eoi(struct irq_data *d)
>   	 * Reading the interrupt reason automatically acknowledges and masks
>   	 * the IRQ, so we just unmask it here if needed.
>   	 */
> -	if (!irqd_irq_disabled(d) && !irqd_irq_masked(d))
> +	if (!irqd_irq_masked(d))
>   		aic_irq_unmask(d);
>   }
>   
> 

Looks good to me. I can't remember exactly where this code came from, 
but looking again at the irqchip code it's clear that the mask state and 
hardware mask always have to be in sync.

Acked-by: Hector Martin <marcan@marcan.st>

-- 
Hector Martin (marcan@marcan.st)
Public Key: https://mrcn.st/pub

  reply	other threads:[~2021-08-18 11:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 10:09 [PATCH] irqchip/apple-aic: fix irq_disable from within irq handlers Sven Peter
2021-08-18 11:35 ` Hector Martin [this message]
2021-08-20 12:22 ` Marc Zyngier
2021-08-20 13:34 ` [irqchip: irq/irqchip-next] irqchip/apple-aic: Fix " irqchip-bot for Sven Peter

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=9b2805ec-e5b4-bb1b-abee-0bff7e3dbf24@marcan.st \
    --to=marcan@marcan.st \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=sven@svenpeter.dev \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /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).