linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: 414777006@qq.com
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	Mengguang Peng <pengmengguang@phytium.com.cn>
Subject: Re: [PATCH] Fixed: ARM64 GIC ITS could not resume from suspend
Date: Tue, 13 Apr 2021 11:43:08 +0100	[thread overview]
Message-ID: <87zgy2mpmr.wl-maz@kernel.org> (raw)
In-Reply-To: <tencent_F6258BE95A1FE59621DE0329FC771C61000A@qq.com>

On Tue, 13 Apr 2021 07:40:10 +0100,
414777006@qq.com wrote:
> 
> From: Mengguang Peng <pengmengguang@phytium.com.cn>
> 
> - After ITS suspend, in the ATF(arm-trusted-firmware),
>   gicv3_rdistif_init_restore() just restore GICR_CTLR.Enable_LPIs bit
>   of boot cpu.
> 
> - In its_cpu_init_lpis() of kernel, gic_data_rdist()->lpi_enable
>   will block setting GICR_CTLR_ENABLE_LPIS bit of the other CPUs
>   when ITS resume after suspend.
> 
> Signed-off-by: Mengguang Peng <pengmengguang@phytium.com.cn>
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index ed46e60..8167397 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -4777,7 +4777,7 @@ static int its_save_disable(void)
>  static void its_restore_enable(void)
>  {
>  	struct its_node *its;
> -	int ret;
> +	int ret, cpu;
>  
>  	raw_spin_lock(&its_lock);
>  	list_for_each_entry(its, &its_nodes, entry) {
> @@ -4831,6 +4831,22 @@ static void its_restore_enable(void)
>  		    GITS_TYPER_HCC(gic_read_typer(base + GITS_TYPER)))
>  			its_cpu_init_collection(its);
>  	}
> +
> +	/*
> +	 * Enable LPIs: firmware just restore GICR_CTLR.Enable_LPIs
> +	 * of boot cpu, the other CPUs also should be restore.
> +	 */
> +	for_each_online_cpu(cpu) {
> +		void __iomem *rbase = gic_data_rdist_cpu(cpu)->rd_base;
> +		u32 val;
> +
> +		/* Enable LPIs */
> +		val = readl_relaxed(rbase + GICR_CTLR);
> +		if (val)
> +			continue;
> +		val |= GICR_CTLR_ENABLE_LPIS;
> +		writel_relaxed(val, rbase + GICR_CTLR);
> +	}
>  	raw_spin_unlock(&its_lock);
>  }

This looks completely flawed. If GICR_CTLR.Enable_LPIs is clear on
resume, how can you trust the rest of the bits in the register? How
can you trust *any* register in the redistributor?

And what makes you think it is valid or safe to blindly enable LPIs
without even checking whether they were enabled the first place?

I will reiterate my take on this: if the firmware messes with the RD
on suspend, please address the problem in the firmware so that the RDs
are correctly restored on each CPU.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

           reply	other threads:[~2021-04-13 10:43 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <tencent_F6258BE95A1FE59621DE0329FC771C61000A@qq.com>]

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=87zgy2mpmr.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=414777006@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pengmengguang@phytium.com.cn \
    --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).