Skip to content

Commit fc2ed9d

Browse files
committed
power: Add stype parameter in power_suspend/resume eventhandlers
Add enum sleep_type stype parameter in power_suspend/resume event handlers, as with the introduction of s2idle there are more than one type of suspend. Reviewed by: bz Approved by: bz Sponsored by: The FreeBSD Foundation
1 parent 0faa9ca commit fc2ed9d

File tree

10 files changed

+37
-27
lines changed

10 files changed

+37
-27
lines changed

sys/amd64/acpica/acpi_wakeup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extern int acpi_susp_bounce;
7474
extern struct susppcb **susppcbs;
7575
static cpuset_t suspcpus;
7676

77-
static void acpi_stop_beep(void *);
77+
static void acpi_stop_beep(void *, enum power_stype);
7878

7979
static int acpi_wakeup_ap(struct acpi_softc *, int);
8080
static void acpi_wakeup_cpus(struct acpi_softc *);
@@ -88,7 +88,7 @@ static void acpi_wakeup_cpus(struct acpi_softc *);
8888
} while (0)
8989

9090
static void
91-
acpi_stop_beep(void *arg)
91+
acpi_stop_beep(void *arg, enum power_stype stype)
9292
{
9393

9494
if (acpi_resume_beep != 0)

sys/cam/ata/ata_da.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <sys/malloc.h>
4545
#include <sys/endian.h>
4646
#include <sys/cons.h>
47+
#include <sys/power.h>
4748
#include <sys/proc.h>
4849
#include <sys/reboot.h>
4950
#include <sys/sbuf.h>
@@ -878,8 +879,8 @@ static int adaerror(union ccb *ccb, uint32_t cam_flags,
878879
uint32_t sense_flags);
879880
static callout_func_t adasendorderedtag;
880881
static void adashutdown(void *arg, int howto);
881-
static void adasuspend(void *arg);
882-
static void adaresume(void *arg);
882+
static void adasuspend(void *arg, enum power_stype stype);
883+
static void adaresume(void *arg, enum power_stype stype);
883884

884885
#ifndef ADA_DEFAULT_TIMEOUT
885886
#define ADA_DEFAULT_TIMEOUT 30 /* Timeout in seconds */
@@ -3747,7 +3748,7 @@ adashutdown(void *arg, int howto)
37473748
}
37483749

37493750
static void
3750-
adasuspend(void *arg)
3751+
adasuspend(void *arg, enum power_stype stype)
37513752
{
37523753

37533754
adaflush();
@@ -3760,7 +3761,7 @@ adasuspend(void *arg)
37603761
}
37613762

37623763
static void
3763-
adaresume(void *arg)
3764+
adaresume(void *arg, enum power_stype stype)
37643765
{
37653766
struct cam_periph *periph;
37663767
struct ada_softc *softc;

sys/cam/nvme/nvme_da.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <sys/eventhandler.h>
4444
#include <sys/malloc.h>
4545
#include <sys/cons.h>
46+
#include <sys/power.h>
4647
#include <sys/proc.h>
4748
#include <sys/reboot.h>
4849
#include <sys/sbuf.h>
@@ -159,7 +160,7 @@ static void ndadone(struct cam_periph *periph,
159160
static int ndaerror(union ccb *ccb, uint32_t cam_flags,
160161
uint32_t sense_flags);
161162
static void ndashutdown(void *arg, int howto);
162-
static void ndasuspend(void *arg);
163+
static void ndasuspend(void *arg, enum power_stype stype);
163164

164165
#ifndef NDA_DEFAULT_SEND_ORDERED
165166
#define NDA_DEFAULT_SEND_ORDERED 1
@@ -1365,7 +1366,7 @@ ndashutdown(void *arg, int howto)
13651366
}
13661367

13671368
static void
1368-
ndasuspend(void *arg)
1369+
ndasuspend(void *arg, enum power_stype stype)
13691370
{
13701371

13711372
ndaflush();

sys/compat/linuxkpi/common/src/linux_acpi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sys/bus.h>
3434
#include <sys/eventhandler.h>
3535
#include <sys/kernel.h>
36+
#include <sys/power.h>
3637

3738
#include <contrib/dev/acpica/include/acpi.h>
3839
#include <dev/acpica/acpivar.h>
@@ -118,7 +119,8 @@ acpi_evaluate_dsm(ACPI_HANDLE ObjHandle, const guid_t *guid,
118119
}
119120

120121
static void
121-
linux_handle_power_suspend_event(void *arg __unused)
122+
linux_handle_power_suspend_event(void *arg __unused,
123+
enum power_stype stype __unused)
122124
{
123125
/*
124126
* Only support S3 for now.
@@ -131,7 +133,8 @@ linux_handle_power_suspend_event(void *arg __unused)
131133
}
132134

133135
static void
134-
linux_handle_power_resume_event(void *arg __unused)
136+
linux_handle_power_resume_event(void *arg __unused,
137+
enum power_stype stype __unused)
135138
{
136139
linux_acpi_target_sleep_state = ACPI_STATE_S0;
137140
pm_suspend_target_state = PM_SUSPEND_ON;

sys/dev/acpica/acpi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,10 +3468,10 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
34683468
return_ACPI_STATUS (AE_OK);
34693469
}
34703470

3471-
EVENTHANDLER_INVOKE(power_suspend_early);
3471+
EVENTHANDLER_INVOKE(power_suspend_early, stype);
34723472
stop_all_proc();
34733473
suspend_all_fs();
3474-
EVENTHANDLER_INVOKE(power_suspend);
3474+
EVENTHANDLER_INVOKE(power_suspend, stype);
34753475

34763476
#ifdef EARLY_AP_STARTUP
34773477
MPASS(mp_ncpus == 1 || smp_started);
@@ -3632,7 +3632,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
36323632
resume_all_fs();
36333633
resume_all_proc();
36343634

3635-
EVENTHANDLER_INVOKE(power_resume);
3635+
EVENTHANDLER_INVOKE(power_resume, stype);
36363636

36373637
/* Allow another sleep request after a while. */
36383638
callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME);

sys/dev/acpica/acpi_timer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <sys/module.h>
3535
#include <sys/sysctl.h>
3636
#include <sys/timetc.h>
37+
#include <sys/power.h>
3738

3839
#include <machine/bus.h>
3940
#include <machine/resource.h>
@@ -69,8 +70,10 @@ bool acpi_timer_disabled = false;
6970
static void acpi_timer_identify(driver_t *driver, device_t parent);
7071
static int acpi_timer_probe(device_t dev);
7172
static int acpi_timer_attach(device_t dev);
72-
static void acpi_timer_resume_handler(struct timecounter *);
73-
static void acpi_timer_suspend_handler(struct timecounter *);
73+
static void acpi_timer_resume_handler(struct timecounter *,
74+
enum power_stype);
75+
static void acpi_timer_suspend_handler(struct timecounter *,
76+
enum power_stype);
7477
static u_int acpi_timer_get_timecount(struct timecounter *tc);
7578
static u_int acpi_timer_get_timecount_safe(struct timecounter *tc);
7679
static int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
@@ -235,7 +238,7 @@ acpi_timer_attach(device_t dev)
235238
}
236239

237240
static void
238-
acpi_timer_resume_handler(struct timecounter *newtc)
241+
acpi_timer_resume_handler(struct timecounter *newtc, enum power_stype stype)
239242
{
240243
struct timecounter *tc;
241244

@@ -251,7 +254,7 @@ acpi_timer_resume_handler(struct timecounter *newtc)
251254
}
252255

253256
static void
254-
acpi_timer_suspend_handler(struct timecounter *newtc)
257+
acpi_timer_suspend_handler(struct timecounter *newtc, enum power_stype stype)
255258
{
256259
struct timecounter *tc;
257260

sys/dev/vt/vt_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ static void vt_update_static(void *);
195195
#ifndef SC_NO_CUTPASTE
196196
static void vt_mouse_paste(void);
197197
#endif
198-
static void vt_suspend_handler(void *priv);
199-
static void vt_resume_handler(void *priv);
198+
static void vt_suspend_handler(void *priv, enum power_stype stype);
199+
static void vt_resume_handler(void *priv, enum power_stype stype);
200200

201201
SET_DECLARE(vt_drv_set, struct vt_driver);
202202

@@ -3330,7 +3330,7 @@ vt_replace_backend(const struct vt_driver *drv, void *softc)
33303330
}
33313331

33323332
static void
3333-
vt_suspend_handler(void *priv)
3333+
vt_suspend_handler(void *priv, enum power_stype stype)
33343334
{
33353335
struct vt_device *vd;
33363336

@@ -3341,7 +3341,7 @@ vt_suspend_handler(void *priv)
33413341
}
33423342

33433343
static void
3344-
vt_resume_handler(void *priv)
3344+
vt_resume_handler(void *priv, enum power_stype stype)
33453345
{
33463346
struct vt_device *vd;
33473347

sys/dev/xen/control/control.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include <sys/smp.h>
9292
#include <sys/eventhandler.h>
9393
#include <sys/timetc.h>
94+
#include <sys/power.h>
9495

9596
#include <geom/geom.h>
9697

@@ -175,12 +176,12 @@ xctrl_suspend(void)
175176
cpuset_t cpu_suspend_map;
176177
#endif
177178

178-
EVENTHANDLER_INVOKE(power_suspend_early);
179+
EVENTHANDLER_INVOKE(power_suspend_early, POWER_STYPE_SUSPEND_TO_MEM);
179180
xs_lock();
180181
stop_all_proc();
181182
xs_unlock();
182183
suspend_all_fs();
183-
EVENTHANDLER_INVOKE(power_suspend);
184+
EVENTHANDLER_INVOKE(power_suspend, POWER_STYPE_SUSPEND_TO_MEM);
184185

185186
#ifdef EARLY_AP_STARTUP
186187
MPASS(mp_ncpus == 1 || smp_started);
@@ -297,7 +298,7 @@ xctrl_suspend(void)
297298
resume_all_fs();
298299
resume_all_proc();
299300

300-
EVENTHANDLER_INVOKE(power_resume);
301+
EVENTHANDLER_INVOKE(power_resume, POWER_STYPE_SUSPEND_TO_MEM);
301302

302303
if (bootverbose)
303304
printf("System resumed after suspension\n");

sys/i386/acpica/acpi_wakeup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static cpuset_t suspcpus;
8484
static struct susppcb **susppcbs;
8585
#endif
8686

87-
static void acpi_stop_beep(void *);
87+
static void acpi_stop_beep(void *, enum power_stype);
8888

8989
#ifdef SMP
9090
static int acpi_wakeup_ap(struct acpi_softc *, int);
@@ -100,7 +100,7 @@ static void acpi_wakeup_cpus(struct acpi_softc *);
100100
} while (0)
101101

102102
static void
103-
acpi_stop_beep(void *arg)
103+
acpi_stop_beep(void *arg, enum power_stype stype)
104104
{
105105

106106
if (acpi_resume_beep != 0)

sys/sys/eventhandler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sys/lock.h>
3434
#include <sys/ktr.h>
3535
#include <sys/mutex.h>
36+
#include <sys/power.h>
3637
#include <sys/queue.h>
3738

3839
#ifdef VIMAGE
@@ -201,7 +202,7 @@ EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn); /* after fs sync */
201202
EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn);
202203

203204
/* Power state change events */
204-
typedef void (*power_change_fn)(void *);
205+
typedef void (*power_change_fn)(void *, enum power_stype stype);
205206
EVENTHANDLER_DECLARE(power_resume, power_change_fn);
206207
EVENTHANDLER_DECLARE(power_suspend, power_change_fn);
207208
EVENTHANDLER_DECLARE(power_suspend_early, power_change_fn);

0 commit comments

Comments
 (0)