public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: geert@linux-m68k.org
Cc: jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com, daniel@0x0f.com,
	laurent@vivier.eu, linux-kernel@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, linux-pm@vger.kernel.org,
	sre@kernel.org
Subject: Re: [PATCH v3 2/2] m68k: virt: Switch to qemu-virt-ctrl driver
Date: Wed, 8 Apr 2026 09:17:41 +0800	[thread overview]
Message-ID: <adWstVinlyrj5t8-@google.com> (raw)
In-Reply-To: <20260222173225.1105572-3-visitorckw@gmail.com>

Hi Geert,

On Sun, Feb 22, 2026 at 05:32:25PM +0000, Kuan-Wei Chiu wrote:
> Register the "qemu-virt-ctrl" platform device during board
> initialization to utilize the new generic power/reset driver.
> 
> Consequently, remove the legacy reset and power-off implementations
> specific to the virt machine. The platform's mach_reset callback is
> updated to call do_kernel_restart(), bridging the legacy m68k reboot
> path to the generic kernel restart handler framework for this machine.
> 
> To prevent any regressions in reboot or power-off functionality when
> the driver is not built-in, explicitly select POWER_RESET and
> POWER_RESET_QEMU_VIRT_CTRL for the VIRT machine in Kconfig.machine.
> 
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>

Since the next merge window is approaching, is there anything else
needed for this to be picked up via the m68k tree?

Regards,
Kuan-Wei

> ---
> Changes in v3:
> - Add 'select POWER_RESET' and 'select POWER_RESET_QEMU_VIRT_CTRL' in
>   Kconfig.machine to avoid restart/power-off regressions.
> 
>  arch/m68k/Kconfig.machine |  2 ++
>  arch/m68k/virt/config.c   | 42 +--------------------------------------
>  arch/m68k/virt/platform.c | 20 ++++++++++++++++---
>  3 files changed, 20 insertions(+), 44 deletions(-)
> 
> diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
> index de39f23b180e..624e6b27f394 100644
> --- a/arch/m68k/Kconfig.machine
> +++ b/arch/m68k/Kconfig.machine
> @@ -133,6 +133,8 @@ config VIRT
>  	select GOLDFISH_TIMER
>  	select GOLDFISH_TTY
>  	select M68040
> +	select POWER_RESET
> +	select POWER_RESET_QEMU_VIRT_CTRL
>  	select RTC_CLASS
>  	select RTC_DRV_GOLDFISH
>  	select TTY
> diff --git a/arch/m68k/virt/config.c b/arch/m68k/virt/config.c
> index 632ba200ad42..b338e2a8da6a 100644
> --- a/arch/m68k/virt/config.c
> +++ b/arch/m68k/virt/config.c
> @@ -13,18 +13,6 @@
>  
>  struct virt_booter_data virt_bi_data;
>  
> -#define VIRT_CTRL_REG_FEATURES	0x00
> -#define VIRT_CTRL_REG_CMD	0x04
> -
> -static struct resource ctrlres;
> -
> -enum {
> -	CMD_NOOP,
> -	CMD_RESET,
> -	CMD_HALT,
> -	CMD_PANIC,
> -};
> -
>  static void virt_get_model(char *str)
>  {
>  	/* str is 80 characters long */
> @@ -33,25 +21,9 @@ static void virt_get_model(char *str)
>  		(u8)(virt_bi_data.qemu_version >> 16),
>  		(u8)(virt_bi_data.qemu_version >> 8));
>  }
> -
> -static void virt_halt(void)
> -{
> -	void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
> -
> -	iowrite32be(CMD_HALT, base + VIRT_CTRL_REG_CMD);
> -	local_irq_disable();
> -	while (1)
> -		;
> -}
> -
>  static void virt_reset(void)
>  {
> -	void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
> -
> -	iowrite32be(CMD_RESET, base + VIRT_CTRL_REG_CMD);
> -	local_irq_disable();
> -	while (1)
> -		;
> +	do_kernel_restart(NULL);
>  }
>  
>  /*
> @@ -113,20 +85,8 @@ void __init config_virt(void)
>  		 virt_bi_data.tty.mmio);
>  	setup_earlycon(earlycon);
>  
> -	ctrlres = (struct resource)
> -		   DEFINE_RES_MEM_NAMED(virt_bi_data.ctrl.mmio, 0x100,
> -					"virtctrl");
> -
> -	if (request_resource(&iomem_resource, &ctrlres)) {
> -		pr_err("Cannot allocate virt controller resource\n");
> -		return;
> -	}
> -
>  	mach_init_IRQ = virt_init_IRQ;
>  	mach_sched_init = virt_sched_init;
>  	mach_get_model = virt_get_model;
>  	mach_reset = virt_reset;
> -	mach_halt = virt_halt;
> -
> -	register_platform_power_off(virt_halt);
>  }
> diff --git a/arch/m68k/virt/platform.c b/arch/m68k/virt/platform.c
> index 1560c4140ab9..764f556b4b32 100644
> --- a/arch/m68k/virt/platform.c
> +++ b/arch/m68k/virt/platform.c
> @@ -30,7 +30,10 @@ static int __init virt_platform_init(void)
>  		DEFINE_RES_MEM(virt_bi_data.rtc.mmio + 0x1000, 0x1000),
>  		DEFINE_RES_IRQ(virt_bi_data.rtc.irq + 1),
>  	};
> -	struct platform_device *pdev1, *pdev2;
> +	const struct resource virt_ctrl_res[] = {
> +		DEFINE_RES_MEM(virt_bi_data.ctrl.mmio, 0x100),
> +	};
> +	struct platform_device *pdev1, *pdev2, *pdev3;
>  	struct platform_device *pdevs[VIRTIO_BUS_NB];
>  	unsigned int i;
>  	int ret = 0;
> @@ -57,19 +60,30 @@ static int __init virt_platform_init(void)
>  		goto err_unregister_tty;
>  	}
>  
> +	pdev3 = platform_device_register_simple("qemu-virt-ctrl",
> +						PLATFORM_DEVID_NONE,
> +						virt_ctrl_res,
> +						ARRAY_SIZE(virt_ctrl_res));
> +	if (IS_ERR(pdev3)) {
> +		ret = PTR_ERR(pdev3);
> +		goto err_unregister_rtc;
> +	}
> +
>  	for (i = 0; i < VIRTIO_BUS_NB; i++) {
>  		pdevs[i] = virt_virtio_init(i);
>  		if (IS_ERR(pdevs[i])) {
>  			ret = PTR_ERR(pdevs[i]);
> -			goto err_unregister_rtc_virtio;
> +			goto err_unregister_virtio;
>  		}
>  	}
>  
>  	return 0;
>  
> -err_unregister_rtc_virtio:
> +err_unregister_virtio:
>  	while (i > 0)
>  		platform_device_unregister(pdevs[--i]);
> +	platform_device_unregister(pdev3);
> +err_unregister_rtc:
>  	platform_device_unregister(pdev2);
>  err_unregister_tty:
>  	platform_device_unregister(pdev1);
> -- 
> 2.53.0.345.g96ddfc5eaa-goog
> 

  reply	other threads:[~2026-04-08  1:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-22 17:32 [PATCH v3 0/2] Add QEMU virt-ctrl driver and update m68k virt Kuan-Wei Chiu
2026-02-22 17:32 ` [PATCH v3 1/2] power: reset: Add QEMU virt-ctrl driver Kuan-Wei Chiu
2026-04-02 21:52   ` Sebastian Reichel
2026-04-08  9:10     ` Geert Uytterhoeven
2026-04-08  9:10       ` Geert Uytterhoeven
2026-02-22 17:32 ` [PATCH v3 2/2] m68k: virt: Switch to qemu-virt-ctrl driver Kuan-Wei Chiu
2026-04-08  1:17   ` Kuan-Wei Chiu [this message]
2026-04-08  9:12   ` Geert Uytterhoeven

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=adWstVinlyrj5t8-@google.com \
    --to=visitorckw@gmail.com \
    --cc=daniel@0x0f.com \
    --cc=eleanor15x@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=laurent@vivier.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /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