From: Stafford Horne <shorne@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Jonas Bonn <jonas@southpole.se>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Kees Cook <keescook@chromium.org>,
"Peter Zijlstra \(Intel\)" <peterz@infradead.org>,
Masahiro Yamada <masahiroy@kernel.org>,
"Russell King \(Oracle\)" <rmk+kernel@armlinux.org.uk>,
Openrisc <openrisc@lists.librecores.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: [PATCH] openrisc: Allow power off handler overriding
Date: Sat, 21 May 2022 10:53:21 +0900 [thread overview]
Message-ID: <20220521015322.188707-1-shorne@gmail.com> (raw)
The OpenRISC platform always defines a default pm_power_off hanlder
which is only useful for simulators. Having this set also means power
management drivers like syscon-power are not able to wire in their own
pm_power_off handlers.
Fix this by not setting the pm_power_off handler by default and fallback
to the simulator power off handler if no handler is set.
This has been tested with a new OpenRISC virt platform I am working on
for QEMU.
https://github.com/stffrdhrn/qemu/commits/or1k-virt
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
arch/openrisc/kernel/process.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 3c0c91bcdcba..1cca89a3b0c8 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -60,6 +60,16 @@ void machine_restart(char *cmd)
while (1);
}
+/*
+ * This is used if pm_power_off has not been set by a power management
+ * driver, in this case we can assume we are on a simulator. On
+ * OpenRISC simulators l.nop 1 will trigger the simulator exit.
+ */
+static void default_power_off(void)
+{
+ __asm__("l.nop 1");
+}
+
/*
* Similar to machine_power_off, but don't shut off power. Add code
* here to freeze the system for e.g. post-mortem debug purpose when
@@ -75,7 +85,10 @@ void machine_halt(void)
void machine_power_off(void)
{
printk(KERN_INFO "*** MACHINE POWER OFF ***\n");
- __asm__("l.nop 1");
+ if (pm_power_off != NULL)
+ pm_power_off();
+ else
+ default_power_off();
}
/*
@@ -89,7 +102,7 @@ void arch_cpu_idle(void)
mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME);
}
-void (*pm_power_off) (void) = machine_power_off;
+void (*pm_power_off)(void) = NULL;
EXPORT_SYMBOL(pm_power_off);
/*
--
2.31.1
reply other threads:[~2022-05-21 1:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220521015322.188707-1-shorne@gmail.com \
--to=shorne@gmail.com \
--cc=Jason@zx2c4.com \
--cc=adobriyan@gmail.com \
--cc=jonas@southpole.se \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=openrisc@lists.librecores.org \
--cc=peterz@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
/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).