In message <[email protected]>, Aymeric Wibo 
writ
es:
> The branch main has been updated by obiwac:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=87e2b532ec9e9504ac743931ffae5286
> 79a1f4c0
>
> commit 87e2b532ec9e9504ac743931ffae528679a1f4c0
> Author:     Aymeric Wibo <[email protected]>
> AuthorDate: 2025-09-18 09:45:27 +0000
> Commit:     Aymeric Wibo <[email protected]>
> CommitDate: 2025-09-18 09:49:17 +0000
>
>     Revert "sys/power: Sleep type reporting by PM backends"
>     
>     This reverts commit e779891327b1d9b9ab10ba482e59f498790505a7.
>     
>     PR:             289634
> ---
>  sys/dev/acpica/acpi.c |  6 ++----
>  sys/kern/subr_power.c | 46 +++++-----------------------------------------
>  sys/sys/power.h       |  3 +--
>  3 files changed, 8 insertions(+), 47 deletions(-)
>
> diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
> index 702e1ecb5340..8dd879a573cc 100644
> --- a/sys/dev/acpica/acpi.c
> +++ b/sys/dev/acpica/acpi.c
> @@ -734,8 +734,7 @@ acpi_attach(device_t dev)
>       goto out;
>  
>      /* Register ACPI again to pass the correct argument of pm_func. */
> -    power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, sc,
> -     acpi_supported_stypes);
> +    power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, sc);
>  
>      acpi_platform_osc(dev);
>  
> @@ -4777,8 +4776,7 @@ acpi_pm_register(void *arg)
>      if (!cold || resource_disabled("acpi", 0))
>       return;
>  
> -    power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, NULL,
> -     acpi_supported_stypes);
> +    power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, NULL);
>  }
>  
>  SYSINIT(power, SI_SUB_KLD, SI_ORDER_ANY, acpi_pm_register, NULL);
> diff --git a/sys/kern/subr_power.c b/sys/kern/subr_power.c
> index 44ad82860649..eb5bd03f5018 100644
> --- a/sys/kern/subr_power.c
> +++ b/sys/kern/subr_power.c
> @@ -39,14 +39,13 @@
>  #include <sys/systm.h>
>  #include <sys/taskqueue.h>
>  
> -enum power_stype      power_standby_stype    = POWER_STYPE_UNKNOWN;
> -enum power_stype      power_suspend_stype    = POWER_STYPE_UNKNOWN;
> -enum power_stype      power_hibernate_stype  = POWER_STYPE_UNKNOWN;
> +enum power_stype      power_standby_stype    = POWER_STYPE_STANDBY;
> +enum power_stype      power_suspend_stype    = POWER_STYPE_SUSPEND_TO_IDLE;
> +enum power_stype      power_hibernate_stype  = POWER_STYPE_HIBERNATE;
>  
>  static u_int          power_pm_type  = POWER_PM_TYPE_NONE;
>  static power_pm_fn_t  power_pm_fn    = NULL;
>  static void          *power_pm_arg   = NULL;
> -static bool           power_pm_supported[POWER_STYPE_COUNT] = {0};
>  static struct task    power_pm_task;
>  
>  enum power_stype
> @@ -71,26 +70,6 @@ power_stype_to_name(enum power_stype stype)
>       return (power_stype_names[stype]);
>  }
>  
> -static int
> -sysctl_supported_stypes(SYSCTL_HANDLER_ARGS)
> -{
> -     int error;
> -     struct sbuf sb;
> -     enum power_stype stype;
> -
> -     sbuf_new(&sb, NULL, 32, SBUF_AUTOEXTEND);
> -     for (stype = 0; stype < POWER_STYPE_COUNT; stype++) {
> -             if (power_pm_supported[stype])
> -                     sbuf_printf(&sb, "%s ", power_stype_to_name(stype));
> -     }
> -     sbuf_trim(&sb);
> -     sbuf_finish(&sb);
> -     error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
> -     sbuf_delete(&sb);
> -
> -     return (error);
> -}
> -
>  static int
>  power_sysctl_stype(SYSCTL_HANDLER_ARGS)
>  {
> @@ -107,8 +86,7 @@ power_sysctl_stype(SYSCTL_HANDLER_ARGS)
>       new_stype = power_name_to_stype(name);
>       if (new_stype == POWER_STYPE_UNKNOWN)
>               return (EINVAL);
> -     if (!power_pm_supported[new_stype])
> -             return (EOPNOTSUPP);
> +     /* TODO Check to see if the new stype is supported. */
>       if (new_stype != old_stype)
>               *(enum power_stype *)oidp->oid_arg1 = new_stype;
>       return (0);
> @@ -117,9 +95,6 @@ power_sysctl_stype(SYSCTL_HANDLER_ARGS)
>  static SYSCTL_NODE(_kern, OID_AUTO, power, CTLFLAG_RW, 0,
>      "Generic power management related sysctls");
>  
> -SYSCTL_PROC(_kern_power, OID_AUTO, supported_stype,
> -    CTLTYPE_STRING | CTLFLAG_RD, 0, 0, sysctl_supported_stypes, "A",
> -    "List supported sleep types");
>  SYSCTL_PROC(_kern_power, OID_AUTO, standby, CTLTYPE_STRING | CTLFLAG_RW,
>      &power_standby_stype, 0, power_sysctl_stype, "A",
>      "Sleep type to enter on standby");
> @@ -139,8 +114,7 @@ power_pm_deferred_fn(void *arg, int pending)
>  }
>  
>  int
> -power_pm_register(u_int pm_type, power_pm_fn_t pm_fn, void *pm_arg,
> -    bool pm_supported[static POWER_STYPE_COUNT])
> +power_pm_register(u_int pm_type, power_pm_fn_t pm_fn, void *pm_arg)
>  {
>       int     error;
>  
> @@ -149,16 +123,6 @@ power_pm_register(u_int pm_type, power_pm_fn_t pm_fn, vo
> id *pm_arg,
>               power_pm_type   = pm_type;
>               power_pm_fn     = pm_fn;
>               power_pm_arg    = pm_arg;
> -             memcpy(power_pm_supported, pm_supported,
> -                 sizeof(power_pm_supported));
> -             if (power_pm_supported[POWER_STYPE_STANDBY])
> -                     power_standby_stype = POWER_STYPE_STANDBY;
> -             if (power_pm_supported[POWER_STYPE_SUSPEND_TO_IDLE])
> -                     power_suspend_stype = POWER_STYPE_SUSPEND_TO_IDLE;
> -             else if (power_pm_supported[POWER_STYPE_SUSPEND_TO_MEM])
> -                     power_suspend_stype = POWER_STYPE_SUSPEND_TO_MEM;
> -             if (power_pm_supported[POWER_STYPE_HIBERNATE])
> -                     power_hibernate_stype = POWER_STYPE_HIBERNATE;
>               error = 0;
>               TASK_INIT(&power_pm_task, 0, power_pm_deferred_fn, NULL);
>       } else {
> diff --git a/sys/sys/power.h b/sys/sys/power.h
> index 33ace400bfd2..44d7fc354423 100644
> --- a/sys/sys/power.h
> +++ b/sys/sys/power.h
> @@ -91,8 +91,7 @@ extern const char   *power_stype_to_name(enum power_stype _
> stype);
>  
>  typedef int (*power_pm_fn_t)(u_long _cmd, void* _arg, enum power_stype _styp
> e);
>  extern int    power_pm_register(u_int _pm_type, power_pm_fn_t _pm_fn,
> -                     void *_pm_arg,
> -                     bool _pm_supported[static POWER_STYPE_COUNT]);
> +                     void *_pm_arg);
>  extern u_int  power_pm_get_type(void);
>  extern void   power_pm_suspend(int);
>  
>

cThank you. This resolves the poweroff hang on my UEFI machines (HP 840 and 
Framework 13 and the poweroff panic on my non-UEFI machines (all ASUS).


-- 
Cheers,
Cy Schubert <[email protected]>
FreeBSD UNIX:  <[email protected]>   Web:  https://FreeBSD.org
NTP:           <[email protected]>    Web:  https://nwtime.org

                        e**(i*pi)+1=0



Reply via email to