Linux-RISC-V Archive mirror
 help / color / mirror / Atom feed
From: takakura@valinux.co.jp
To: songshuaishuai@tinylab.org, paul.walmsley@sifive.com
Cc: palmer@dabbelt.com, aou@eecs.berkeley.edu, guoren@kernel.org,
	xianting.tian@linux.alibaba.com, takahiro.akashi@linaro.org,
	takakura@valinux.co.jp, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [-fixes] riscv: kexec: Avoid deadlock in kexec crash path
Date: Mon,  6 May 2024 14:10:58 +0900	[thread overview]
Message-ID: <20240506051058.20386-1-takakura@valinux.co.jp> (raw)
In-Reply-To: <0e34cd12-66d8-4432-780a-f08d03a2c95e@sifive.com>

Hi Song and Paul!

>> To avoid the deadlock, this patch directly EOI the irq regardless of
>> the active status of irqchip.
>
>Taking a quick look at the other architectures, looks like no one else is 
>doing this.  Is this addressing a RISC-V-only problem?
>
>> diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c
>> index f6c7135b00d7..d7ddf4d2b243 100644
>> --- a/arch/riscv/kernel/machine_kexec.c
>> +++ b/arch/riscv/kernel/machine_kexec.c
>> @@ -149,20 +149,12 @@ static void machine_kexec_mask_interrupts(void)
>>  
>>  	for_each_irq_desc(i, desc) {
>>  		struct irq_chip *chip;
>> -		int ret;
>>  
>>  		chip = irq_desc_get_chip(desc);
>>  		if (!chip)
>>  			continue;
>>  
>> -		/*
>> -		 * First try to remove the active state. If this
>> -		 * fails, try to EOI the interrupt.
>> -		 */
>> -		ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false);
>> -
>> -		if (ret && irqd_irq_inprogress(&desc->irq_data) &&
>> -		    chip->irq_eoi)
>> +		if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
>>  			chip->irq_eoi(&desc->irq_data);
I think this deadlock is relevant to riscv and arm64 as they both
acquire irqdesc spinlock by calling irq_set_irqchip_state() during their 
machine_kexec_mask_interrupts().

However, I think calling irq_set_irqchip_state() during 
machine_kexec_mask_interrupts() is arm64 specific way of handling EOI 
which is not necessary for riscv.
For arm64, its interrupt controller(gic) seems to have two ways of EOIing 
an interrupt depending on the mode which gic is configured. One of them 
treats EOI as two step procedure, priority drop and deactivation. I think 
irq_set_irqchip_state() is there to handle the deactivation part of 
the procedure.
For riscv, EOI only requires irq_eoi handler to complete EOI and I think 
keeping irq_set_irqchip_state() will only leave this possible deadlock 
without any use. 
So I think it's best we simply remove irq_set_irqchip_state() as Song did.

Sincerely,
Ryo Takakura

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2024-05-06  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 11:10 [PATCH -fixes] riscv: kexec: Avoid deadlock in kexec crash path Song Shuai
2024-03-27 14:36 ` Paul Walmsley
2024-05-06  5:10   ` takakura [this message]
2024-05-24  7:25     ` [-fixes] " Alexandre Ghiti

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=20240506051058.20386-1-takakura@valinux.co.jp \
    --to=takakura@valinux.co.jp \
    --cc=aou@eecs.berkeley.edu \
    --cc=guoren@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=songshuaishuai@tinylab.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=xianting.tian@linux.alibaba.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).