mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Gow <david@davidgow.net>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
	"Michal Simek" <monstr@monstr.eu>,
	"Brendan Higgins" <brendan.higgins@linux.dev>,
	"Rae Moar" <raemoar63@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kunit-dev@googlegroups.com
Subject: Re: [PATCH 3/4] microblaze: reset: Provide a power off handler through an unaligned PC
Date: Wed, 5 Aug 2026 21:59:12 +0800	[thread overview]
Message-ID: <c9989a6b-5b49-40d4-b11e-51a278757eb0@davidgow.net> (raw)
In-Reply-To: <20260804-kunit-microblaze-v1-3-6dcdfe12eb40@weissschuh.net>

Le 04/08/2026 à 13:32, Thomas Weißschuh a écrit :
> microblaze is missing a generic architecture-wide power off mechanism.
> 
> To enable KUnit for microblaze it is necessary for KUnit to shut down
> the machine in a way that QEMU will recognize. The machines emulated by
> QEMU do not provide machine-specific power off functionality which could
> be used.
> However at least the petalogix-s3adsp1800 machine will abort if an
> unaligned instruction is executed. An ugly message will be printed but
> that is not an issue for KUnit.
> 
> Make use of this to provide a power off handler.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> 
> ---
> This is quite hacky. But I didn't find a better solution.

This is hacky. It does work fine here, though, and I also don't have a 
better solution. But I'd feel better about it if a Microblaze person has 
seen it and at least not complained too loudly.

Tested-by: David Gow <david@davidgow.net>

> ---
>   arch/microblaze/Kconfig        |  9 +++++++++
>   arch/microblaze/kernel/reset.c | 21 +++++++++++++++++++++
>   2 files changed, 30 insertions(+)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 484ebb3baedf..0ca8999dd770 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -216,3 +216,12 @@ config MB_MANAGER
>   	  Say N here unless you know what you are doing.
>   
>   endmenu
> +
> +config MB_POWER_OFF_THROUGH_UNALIGNED_PC
> +	bool "Power off through unaligned PC"
> +	help
> +	  This options adds a power off handler which executes an unaligned PC
> +	  so the machine resets in a generic way. This works for the
> +	  petalogix-s3adsp1800 QEMU machine.
> +
> +	  Say N here unless you know what you are doing.
> diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c
> index 3612a20ca16d..4af660deed3b 100644
> --- a/arch/microblaze/kernel/reset.c
> +++ b/arch/microblaze/kernel/reset.c
> @@ -41,3 +41,24 @@ void machine_restart(char *cmd)
>   	pr_emerg("Reboot failed -- System halted\n");
>   	while (1);
>   }
> +
> +#ifdef CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC
> +static int unaligned_pc_sys_off(struct sys_off_data *data)
> +{
> +	__asm__(
> +		"bri 1\n"
> +	);
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static int __init register_unaligned_pc_sys_off(void)
> +{
> +	struct sys_off_handler *sys_off;
> +
> +	sys_off = register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_LOW,
> +					   unaligned_pc_sys_off, NULL);
> +	return PTR_ERR_OR_ZERO(sys_off);
> +}
> +device_initcall(register_unaligned_pc_sys_off);
> +#endif /* CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC */
> 


  reply	other threads:[~2026-08-05 13:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  5:32 [PATCH 0/4] microblaze: KUnit support Thomas Weißschuh
2026-08-04  5:32 ` [PATCH 1/4] microblaze: uaccess: Zero out destination on failed get_user() Thomas Weißschuh
2026-08-05 13:59   ` David Gow
2026-08-04  5:32 ` [PATCH 2/4] microblaze: reset: Call POWER_OFF handlers Thomas Weißschuh
2026-08-05 13:59   ` David Gow
2026-08-31  8:13   ` Michal Simek
2026-08-31 15:39     ` Thomas Weißschuh
2026-08-04  5:32 ` [PATCH 3/4] microblaze: reset: Provide a power off handler through an unaligned PC Thomas Weißschuh
2026-08-05 13:59   ` David Gow [this message]
2026-08-04  5:32 ` [PATCH 4/4] kunit: qemu_configs: Add microblaze configuration Thomas Weißschuh
2026-08-05 13:59   ` David Gow
2026-08-05 19:18     ` Thomas Weißschuh
2026-08-31  8:15       ` Michal Simek
2026-08-31 10:48   ` Michal Simek
2026-08-31 15:43     ` Thomas Weißschuh
2026-09-01 13:33       ` Michal Simek
2026-09-01 18:33         ` Thomas Weißschuh
2026-09-02 10:44           ` Michal Simek
2026-08-31 12:57 ` [PATCH 0/4] microblaze: KUnit support Michal Simek
2026-08-31 15:45   ` Thomas Weißschuh

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=c9989a6b-5b49-40d4-b11e-51a278757eb0@davidgow.net \
    --to=david@davidgow.net \
    --cc=brendan.higgins@linux.dev \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=monstr@monstr.eu \
    --cc=raemoar63@gmail.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

all inboxes | Powered by JetHome®