Re: [PATCH v3 2/2] m68k: virt: Switch to qemu-virt-ctrl driver
Kuan-Wei Chiu <[email protected]>
| Newsgroups | org.kernel.vger.linux-m68k,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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 >