From 90f2f56f2c50bbb62f72f708aa737ba65f2f3ddc Mon Sep 17 00:00:00 2001 From: mlarkin Date: Mon, 6 Apr 2026 19:34:08 +0000 Subject: [PATCH] remove incomplete/never finished loongson hibernate code This was started many years ago and never finished. Ongoing work in hibernate is complicated by having this old code present. ok miod --- sys/arch/loongson/conf/files.loongson | 3 +- sys/arch/loongson/dev/apm.c | 25 +-- sys/arch/loongson/include/apmvar.h | 4 +- sys/arch/loongson/include/hibernate.h | 33 ---- sys/arch/loongson/include/hibernate_var.h | 39 ---- sys/arch/loongson/loongson/autoconf.c | 7 +- .../loongson/loongson/hibernate_machdep.c | 179 ------------------ sys/arch/loongson/loongson/locore.S | 21 +- .../loongson/loongson/loongson2_machdep.c | 9 +- .../loongson/loongson/loongson3_machdep.c | 9 +- sys/arch/loongson/loongson/machdep.c | 9 +- 11 files changed, 8 insertions(+), 330 deletions(-) delete mode 100644 sys/arch/loongson/include/hibernate.h delete mode 100644 sys/arch/loongson/include/hibernate_var.h delete mode 100644 sys/arch/loongson/loongson/hibernate_machdep.c diff --git a/sys/arch/loongson/conf/files.loongson b/sys/arch/loongson/conf/files.loongson index 6b3b2854ec1..30d091de857 100644 --- a/sys/arch/loongson/conf/files.loongson +++ b/sys/arch/loongson/conf/files.loongson @@ -1,4 +1,4 @@ -# $OpenBSD: files.loongson,v 1.26 2020/09/30 22:23:41 patrick Exp $ +# $OpenBSD: files.loongson,v 1.27 2026/04/06 19:34:08 mlarkin Exp $ # Standard stanzas config(8) can't run without maxpartitions 16 @@ -26,7 +26,6 @@ file arch/loongson/loongson/loongson2_machdep.c file arch/loongson/loongson/loongson3_intr.c cpu_loongson3 file arch/loongson/loongson/loongson3_machdep.c cpu_loongson3 file arch/loongson/loongson/machdep.c -file arch/loongson/loongson/hibernate_machdep.c hibernate file arch/loongson/loongson/pciide_machdep.c pciide file arch/loongson/loongson/pmon.c file arch/loongson/loongson/pmon32.S diff --git a/sys/arch/loongson/dev/apm.c b/sys/arch/loongson/dev/apm.c index 83225662a6b..6bdf7f36808 100644 --- a/sys/arch/loongson/dev/apm.c +++ b/sys/arch/loongson/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.44 2024/05/29 06:39:13 jsg Exp $ */ +/* $OpenBSD: apm.c,v 1.45 2026/04/06 19:34:08 mlarkin Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -45,7 +45,6 @@ #include #include #include -#include #include #include @@ -235,17 +234,6 @@ apmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) else error = apm_suspend(APM_IOC_SUSPEND); break; -#ifdef HIBERNATE - case APM_IOC_HIBERNATE: - if ((flag & FWRITE) == 0) - error = EBADF; - else if (sys_platform->suspend == NULL || - sys_platform->resume == NULL) - error = EOPNOTSUPP; - else - error = apm_suspend(APM_IOC_HIBERNATE); - break; -#endif case APM_IOC_PRN_CTL: if ((flag & FWRITE) == 0) error = EBADF; @@ -392,17 +380,6 @@ apm_suspend(int state) suspend_randomness(); -#ifdef HIBERNATE - if (state == APM_IOC_HIBERNATE) { - uvm_pmr_zero_everything(); - if (hibernate_suspend()) { - printf("apm: hibernate_suspend failed"); - uvm_pmr_dirty_everything(); - return (ECANCELED); - } - } -#endif - /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. diff --git a/sys/arch/loongson/include/apmvar.h b/sys/arch/loongson/include/apmvar.h index 39c49251b4e..9509e127590 100644 --- a/sys/arch/loongson/include/apmvar.h +++ b/sys/arch/loongson/include/apmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apmvar.h,v 1.6 2019/01/22 02:36:30 phessler Exp $ */ +/* $OpenBSD: apmvar.h,v 1.7 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2001 Alexander Guy @@ -67,7 +67,6 @@ #define APM_USER_SUSPEND_REQ 0x000A #define APM_SYS_STANDBY_RESUME 0x000B #define APM_CAPABILITY_CHANGE 0x000C /* apm v1.2 */ -#define APM_USER_HIBERNATE_REQ 0x000D #define APM_EVENT_MASK 0xffff #define APM_EVENT_COMPOSE(t,i) ((((i) & 0x7fff) << 16)|((t) & APM_EVENT_MASK)) @@ -117,7 +116,6 @@ struct apm_ctl { if the percentage changes */ #define APM_IOC_STANDBY_REQ _IO('A', 7) /* request standby */ #define APM_IOC_SUSPEND_REQ _IO('A', 8) /* request suspend */ -#define APM_IOC_HIBERNATE _IO('A', 9) /* put system into hibernate */ #ifdef _KERNEL void apm_setinfohook(int (*)(struct apm_power_info *)); diff --git a/sys/arch/loongson/include/hibernate.h b/sys/arch/loongson/include/hibernate.h deleted file mode 100644 index 497a278971e..00000000000 --- a/sys/arch/loongson/include/hibernate.h +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: hibernate.h,v 1.3 2018/06/21 07:33:30 mlarkin Exp $ */ - -/* - * Copyright (c) 2013 Paul Irofti. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include - -/* Loongson hibernate support structures and functions */ - -int get_hibernate_info_md(union hibernate_info *); -void hibernate_flush(void); -void hibernate_enter_resume_mapping(vaddr_t, paddr_t, int); -int hibernate_inflate_skip(union hibernate_info *, paddr_t); -int hibernate_suspend(void); -void hibernate_switch_stack_machdep(void); -void hibernate_resume_machdep(vaddr_t); -void hibernate_activate_resume_pt_machdep(void); -void hibernate_enable_intr_machdep(void); -void hibernate_disable_intr_machdep(void); diff --git a/sys/arch/loongson/include/hibernate_var.h b/sys/arch/loongson/include/hibernate_var.h deleted file mode 100644 index dda04d9906c..00000000000 --- a/sys/arch/loongson/include/hibernate_var.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: hibernate_var.h,v 1.1 2013/06/02 21:46:04 pirofti Exp $ */ - -/* - * Copyright (c) 2013 Paul Irofti. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Loongson hibernate support definitions */ - -#define PAGE_MASK_4M ((256 * PAGE_SIZE) - 1) - -#define PIGLET_PAGE_MASK ~((paddr_t)PAGE_MASK_4M) - -/* - * Steal hibernate pages right after the first page which is reserved - * for the exception area. - * */ -#define HIBERNATE_STACK_PAGE (PAGE_SIZE * 1) -#define HIBERNATE_INFLATE_PAGE (PAGE_SIZE * 2) -#define HIBERNATE_COPY_PAGE (PAGE_SIZE * 3) -#define HIBERNATE_HIBALLOC_PAGE (PAGE_SIZE * 4) - -#define HIBERNATE_RESERVED_PAGES 4 - -/* Use 4MB hibernation chunks */ -#define HIBERNATE_CHUNK_SIZE 0x400000 - -#define HIBERNATE_CHUNK_TABLE_SIZE 0x100000 diff --git a/sys/arch/loongson/loongson/autoconf.c b/sys/arch/loongson/loongson/autoconf.c index 303a350c8ef..86161241f6b 100644 --- a/sys/arch/loongson/loongson/autoconf.c +++ b/sys/arch/loongson/loongson/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.11 2022/09/02 20:06:56 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.12 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. * @@ -20,7 +20,6 @@ #include #include #include -#include #include @@ -134,10 +133,6 @@ diskconf(void) setroot(bootdv, 0, RB_USERREQ); dumpconf(); - -#ifdef HIBERNATE - hibernate_resume(); -#endif /* HIBERNATE */ } void diff --git a/sys/arch/loongson/loongson/hibernate_machdep.c b/sys/arch/loongson/loongson/hibernate_machdep.c deleted file mode 100644 index 393d5c3e500..00000000000 --- a/sys/arch/loongson/loongson/hibernate_machdep.c +++ /dev/null @@ -1,179 +0,0 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.9 2026/03/13 15:54:47 mlarkin Exp $ */ - -/* - * Copyright (c) 2013 Paul Irofti. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "wd.h" -#include "ahci.h" -#include "softraid.h" -#include "sd.h" - -#if NWD > 0 -#include -#include -#endif - -/* - * Loongson MD Hibernate functions - * - * see Loongson hibernate.h for lowmem layout used during hibernate - */ - -/* - * Returns the hibernate write I/O function to use on this machine - */ -hibio_fn -get_hibernate_io_function(dev_t dev) -{ - char *blkname = findblkname(major(dev)); - - if (blkname == NULL) - return NULL; - -#if NWD > 0 - if (strcmp(blkname, "wd") == 0) - return wd_hibernate_io; -#endif -#if NSD > 0 - if (strcmp(blkname, "sd") == 0) { - extern struct cfdriver sd_cd; - extern int ahci_hibernate_io(dev_t dev, daddr_t blkno, - vaddr_t addr, size_t size, int op, void *page); - extern int sr_hibernate_io(dev_t dev, daddr_t blkno, - vaddr_t addr, size_t size, int op, void *page); - struct device *dv = disk_lookup(&sd_cd, DISKUNIT(dev)); - -#if NAHCI > 0 - if (dv && dv->dv_parent && dv->dv_parent->dv_parent && - strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name, - "ahci") == 0) - return ahci_hibernate_io; -#endif -#if NSOFTRAID > 0 - if (dv && dv->dv_parent && dv->dv_parent->dv_parent && - strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name, - "softraid") == 0) - return sr_hibernate_io; - } -#endif -#endif /* NSD > 0 */ - return NULL; -} - -/* - * Gather MD-specific data and store into hiber_info - */ -int -get_hibernate_info_md(union hibernate_info *hiber_info) -{ - int i; - - /* Calculate memory ranges */ - hiber_info->nranges = 0; - hiber_info->image_size = 0; - - for (i = 0; i < MAXMEMSEGS && mem_layout[i].mem_last_page != 0; i++) { - /* XXX: Adjust for stolen pages later */ - hiber_info->ranges[i].base = - mem_layout[i].mem_first_page >> PAGE_SHIFT; - hiber_info->ranges[i].end = - mem_layout[i].mem_last_page >> PAGE_SHIFT; - hiber_info->image_size += - hiber_info->ranges[i].end - hiber_info->ranges[i].base; - hiber_info->nranges++; - } - - return (0); -} - -/* - * Enter a mapping for va->pa in the resume pagetable - */ -void -hibernate_enter_resume_mapping(vaddr_t va, paddr_t pa, int size) -{ - /* XXX TBD */ -} - -/* - * Create the resume-time page table. This table maps the image(pig) area, - * the kernel text area, and various utility pages for use during resume, - * since we cannot overwrite the resuming kernel's page table during inflate - * and expect things to work properly. - */ -void -hibernate_populate_resume_pt(union hibernate_info *hib_info, - paddr_t image_start, paddr_t image_end) -{ - /* XXX TBD */ -} - -/* - * During inflate, certain pages that contain our bookkeeping information - * (eg, the chunk table, scratch pages, etc) need to be skipped over and - * not inflated into. - * - * Returns 1 if the physical page at dest should be skipped, 0 otherwise - */ -int -hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest) -{ - if (dest >= hib_info->piglet_pa && - dest < (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE)) - return (1); - - return (0); -} - -void -hibernate_enable_intr_machdep(void) -{ - enableintr(); -} - -void -hibernate_disable_intr_machdep(void) -{ - disableintr(); -} - -void -hibernate_flush(void) -{ - Mips_SyncCache(curcpu()); -} diff --git a/sys/arch/loongson/loongson/locore.S b/sys/arch/loongson/loongson/locore.S index fe50aa52cbb..f23aa1a1310 100644 --- a/sys/arch/loongson/loongson/locore.S +++ b/sys/arch/loongson/loongson/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.9 2021/02/11 14:44:13 visa Exp $ */ +/* $OpenBSD: locore.S,v 1.10 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -74,25 +74,6 @@ locore_start: nop .end locore_start -#ifdef HIBERNATE - - /* Switch to hibernate resume pagetable */ -LEAF(hibernate_activate_resume_pt_machdep, 0) /* { */ - /* XXX TBD */ - j ra -END(hibernate_activate_resume_pt_machdep) /* } */ - -LEAF(hibernate_switch_stack_machdep, 0) /* { */ - /* XXX TBD */ - j ra -END(hibernate_switch_stack_machdep) /* } */ - -LEAF(hibernate_resume_machdep, 0) /* { */ - j ra -END(hibernate_resume_machdep) /* } */ - -#endif /* HIBERNATE */ - #ifdef MULTIPROCESSOR LEAF(hw_cpu_spinup_trampoline, 0) diff --git a/sys/arch/loongson/loongson/loongson2_machdep.c b/sys/arch/loongson/loongson/loongson2_machdep.c index 17a19f08c07..c70373bd93c 100644 --- a/sys/arch/loongson/loongson/loongson2_machdep.c +++ b/sys/arch/loongson/loongson/loongson2_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loongson2_machdep.c,v 1.17 2019/12/20 13:34:41 visa Exp $ */ +/* $OpenBSD: loongson2_machdep.c,v 1.18 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -30,10 +30,6 @@ #include #include -#ifdef HIBERNATE -#include -#endif /* HIBERNATE */ - #include extern struct phys_mem_desc mem_layout[MAXMEMSEGS]; @@ -164,9 +160,6 @@ loongson2f_setup(u_long memlo, u_long memhi) memlo /* + memhi */; loongson_dma_base = PCI_DDR_BASE ^ DDR_PHYSICAL_BASE; } -#ifdef HIBERNATE - mem_layout[0].mem_first_page += HIBERNATE_RESERVED_PAGES; -#endif /* * Allow access to memory beyond 256MB, by programming the diff --git a/sys/arch/loongson/loongson/loongson3_machdep.c b/sys/arch/loongson/loongson/loongson3_machdep.c index 4935616cb2b..c33056068f9 100644 --- a/sys/arch/loongson/loongson/loongson3_machdep.c +++ b/sys/arch/loongson/loongson/loongson3_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loongson3_machdep.c,v 1.1 2015/08/15 22:31:38 miod Exp $ */ +/* $OpenBSD: loongson3_machdep.c,v 1.2 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2009, 2010, 2014 Miodrag Vallat. @@ -29,10 +29,6 @@ #include #include -#ifdef HIBERNATE -#include -#endif /* HIBERNATE */ - extern struct phys_mem_desc mem_layout[MAXMEMSEGS]; void loongson3a_setup(u_long, u_long); @@ -61,9 +57,6 @@ loongson3a_setup(u_long memlo, u_long memhi) /* do NOT stomp on exception area */ mem_layout[0].mem_first_page = atop(MEMLO_BASE) + 1; mem_layout[0].mem_last_page = atop(MEMLO_BASE) + memlo; -#ifdef HIBERNATE - mem_layout[0].mem_first_page += HIBERNATE_RESERVED_PAGES; -#endif if (memhi != 0) { #ifdef notyet diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c index cd8a1788cf7..0dd88b3a6cf 100644 --- a/sys/arch/loongson/loongson/machdep.c +++ b/sys/arch/loongson/loongson/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.102 2026/04/05 13:11:58 kn Exp $ */ +/* $OpenBSD: machdep.c,v 1.103 2026/04/06 19:34:08 mlarkin Exp $ */ /* * Copyright (c) 2009, 2010, 2014 Miodrag Vallat. @@ -76,10 +76,6 @@ #include #include -#ifdef HIBERNATE -#include -#endif /* HIBERNATE */ - #include #include @@ -705,9 +701,6 @@ mips_init(uint64_t argc, uint64_t argv, uint64_t envp, uint64_t cv, lastkernpa = CKSEG0_TO_PHYS((vaddr_t)ekern); firstkernpage = atop(trunc_page(firstkernpa)); -#ifdef HIBERNATE - firstkernpage -= HIBERNATE_RESERVED_PAGES; -#endif lastkernpage = atop(round_page(lastkernpa)); if (loongson_memlo_alias != 0) {