From: Andrew Jones <ajones@ventanamicro.com>
To: Samuel Holland <samuel.holland@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
linux-riscv@lists.infradead.org,
Albert Ou <aou@eecs.berkeley.edu>,
Conor Dooley <conor.dooley@microchip.com>,
Ley Foon Tan <leyfoon.tan@starfivetech.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Sia Jee Heng <jeeheng.sia@starfivetech.com>,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH] riscv: Do not save the scratch CSR during suspend
Date: Wed, 13 Mar 2024 09:44:18 +0100 [thread overview]
Message-ID: <20240313-a1837dd45cb20198ef5ceae6@orel> (raw)
In-Reply-To: <20240312195641.1830521-1-samuel.holland@sifive.com>
On Tue, Mar 12, 2024 at 12:56:38PM -0700, Samuel Holland wrote:
> While the processor is executing kernel code, the value of the scratch
> CSR is always zero, so there is no need to save the value. Continue to
> write the CSR during the resume flow, so we do not rely on firmware to
> initialize it.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
> arch/riscv/include/asm/suspend.h | 1 -
> arch/riscv/kernel/suspend.c | 3 +--
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h
> index 491296a335d0..6569eefacf38 100644
> --- a/arch/riscv/include/asm/suspend.h
> +++ b/arch/riscv/include/asm/suspend.h
> @@ -13,7 +13,6 @@ struct suspend_context {
> /* Saved and restored by low-level functions */
> struct pt_regs regs;
> /* Saved and restored by high-level functions */
> - unsigned long scratch;
> unsigned long envcfg;
> unsigned long tvec;
> unsigned long ie;
> diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c
> index 299795341e8a..3d306d8a253d 100644
> --- a/arch/riscv/kernel/suspend.c
> +++ b/arch/riscv/kernel/suspend.c
> @@ -14,7 +14,6 @@
>
> void suspend_save_csrs(struct suspend_context *context)
> {
> - context->scratch = csr_read(CSR_SCRATCH);
> if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG))
> context->envcfg = csr_read(CSR_ENVCFG);
> context->tvec = csr_read(CSR_TVEC);
> @@ -37,7 +36,7 @@ void suspend_save_csrs(struct suspend_context *context)
>
> void suspend_restore_csrs(struct suspend_context *context)
> {
> - csr_write(CSR_SCRATCH, context->scratch);
> + csr_write(CSR_SCRATCH, 0);
> if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG))
> csr_write(CSR_ENVCFG, context->envcfg);
> csr_write(CSR_TVEC, context->tvec);
> --
> 2.43.1
>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-03-13 8:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 19:56 [PATCH] riscv: Do not save the scratch CSR during suspend Samuel Holland
2024-03-13 8:44 ` Andrew Jones [this message]
2024-03-15 4:55 ` JeeHeng Sia
2024-03-21 23:51 ` Samuel Holland
2024-04-09 19:43 ` Palmer Dabbelt
2024-04-10 14:20 ` patchwork-bot+linux-riscv
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=20240313-a1837dd45cb20198ef5ceae6@orel \
--to=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=conor.dooley@microchip.com \
--cc=jeeheng.sia@starfivetech.com \
--cc=leyfoon.tan@starfivetech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=samuel.holland@sifive.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