[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <mhng-4f99a87e-9ed6-4d0b-a5b1-596e67198c1a@palmerdabbelt-glaptop>
Date: Sun, 03 Oct 2021 10:10:06 -0700 (PDT)
From: Palmer Dabbelt <palmer@...belt.com>
To: dimitri.ledkov@...onical.com
CC: linux-riscv@...ts.infradead.org,
Paul Walmsley <paul.walmsley@...ive.com>,
aou@...s.berkeley.edu, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv: set default pm_power_off to NULL
On Mon, 06 Sep 2021 17:28:47 PDT (-0700), dimitri.ledkov@...onical.com wrote:
> Set pm_power_off to NULL like on all other architectures, check if it
> is set in machine_halt() and machine_power_off() and fallback to
> default_power_off if no other power driver got registered.
>
> This brings riscv architecture inline with all other architectures,
> and allows to reuse exiting power drivers unmodified.
>
> Kernels without legacy SBI v0.1 extensions (CONFIG_RISCV_SBI_V01 is
> not set), do not set pm_power_off to sbi_shutdown(). There is no
> support for SBI v0.3 system reset extension either. This prevents
> using gpio_poweroff on SiFive HiFive Unmatched.
>
> Tested on SiFive HiFive unmatched, with a dtb specifying gpio-poweroff
> node and kernel complied without CONFIG_RISCV_SBI_V01.
>
> BugLink: https://bugs.launchpad.net/bugs/1942806
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@...onical.com>
> ---
> arch/riscv/kernel/reset.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
> index ee5878d968..9c842c4168 100644
> --- a/arch/riscv/kernel/reset.c
> +++ b/arch/riscv/kernel/reset.c
> @@ -12,7 +12,7 @@ static void default_power_off(void)
> wait_for_interrupt();
> }
>
> -void (*pm_power_off)(void) = default_power_off;
> +void (*pm_power_off)(void) = NULL;
> EXPORT_SYMBOL(pm_power_off);
>
> void machine_restart(char *cmd)
> @@ -23,10 +23,16 @@ void machine_restart(char *cmd)
>
> void machine_halt(void)
> {
> - pm_power_off();
> + if (pm_power_off != NULL)
> + pm_power_off();
> + else
> + default_power_off();
> }
>
> void machine_power_off(void)
> {
> - pm_power_off();
> + if (pm_power_off != NULL)
> + pm_power_off();
> + else
> + default_power_off();
> }
Thanks, this is on for-next.
Powered by blists - more mailing lists