Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159193153
D48735.id170851.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D48735.id170851.diff
View Options
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3634,6 +3634,7 @@
device_printf(sc->acpi_dev, "device_suspend failed\n");
goto backout;
}
+ EVENTHANDLER_INVOKE(acpi_late_suspend, stype);
slp_state |= ACPI_SS_DEV_SUSPEND;
if (stype != POWER_STYPE_SUSPEND_TO_IDLE) {
@@ -3683,6 +3684,7 @@
slp_state &= ~ACPI_SS_GPE_SET;
}
if ((slp_state & ACPI_SS_DEV_SUSPEND) != 0) {
+ EVENTHANDLER_INVOKE(acpi_early_resume, stype);
DEVICE_RESUME(root_bus);
slp_state &= ~ACPI_SS_DEV_SUSPEND;
}
diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c
--- a/sys/dev/acpica/acpi_spmc.c
+++ b/sys/dev/acpica/acpi_spmc.c
@@ -8,12 +8,12 @@
*/
#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/uuid.h>
-#include <sys/kdb.h>
#include <machine/_inttypes.h>
@@ -158,6 +158,9 @@
ACPI_OBJECT *obj;
enum dsm_set_flags dsm_sets;
+ struct eventhandler_entry *eh_suspend;
+ struct eventhandler_entry *eh_resume;
+
bool constraints_populated;
size_t constraint_count;
struct acpi_spmc_constraint *constraints;
@@ -168,6 +171,9 @@
static int acpi_spmc_get_constraints(device_t dev);
static void acpi_spmc_free_constraints(struct acpi_spmc_softc *sc);
+static void acpi_spmc_suspend(device_t dev, enum power_stype stype);
+static void acpi_spmc_resume(device_t dev, enum power_stype stype);
+
static int
acpi_spmc_probe(device_t dev)
{
@@ -207,9 +213,8 @@
static int
acpi_spmc_attach(device_t dev)
{
- struct acpi_spmc_softc *sc;
+ struct acpi_spmc_softc *sc = device_get_softc(dev);
- sc = device_get_softc(dev);
sc->dev = dev;
sc->handle = acpi_get_handle(dev);
@@ -221,7 +226,16 @@
sc->constraints = NULL;
/* Get device constraints. We can only call this once so do this now. */
- acpi_spmc_get_constraints(sc->dev);
+ acpi_spmc_get_constraints(dev);
+
+ if ((sc->eh_suspend = EVENTHANDLER_REGISTER(acpi_late_suspend,
+ acpi_spmc_suspend, dev, 0)) == NULL)
+ device_printf(dev, "Failed to register late suspend event "
+ "handler.\n");
+ if ((sc->eh_resume = EVENTHANDLER_REGISTER(acpi_early_resume,
+ acpi_spmc_resume, dev, 0)) == NULL)
+ device_printf(dev, "Failed to register early resume event "
+ "handler.\n");
return (0);
}
@@ -229,6 +243,13 @@
static int
acpi_spmc_detach(device_t dev)
{
+ struct acpi_spmc_softc *sc = device_get_softc(dev);
+
+ if (sc->eh_suspend != NULL)
+ EVENTHANDLER_DEREGISTER(acpi_pmc_suspend, sc->eh_suspend);
+ if (sc->eh_resume != NULL)
+ EVENTHANDLER_DEREGISTER(acpi_pmc_resume, sc->eh_resume);
+
acpi_spmc_free_constraints(device_get_softc(dev));
return (0);
}
@@ -586,22 +607,24 @@
}
}
-static int
-acpi_spmc_suspend(device_t dev)
+static void
+acpi_spmc_suspend(device_t dev, enum power_stype stype)
{
+ if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
+ return;
+
acpi_spmc_display_off_notif(dev);
acpi_spmc_entry_notif(dev);
-
- return (0);
}
-static int
-acpi_spmc_resume(device_t dev)
+static void
+acpi_spmc_resume(device_t dev, enum power_stype stype)
{
+ if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
+ return;
+
acpi_spmc_exit_notif(dev);
acpi_spmc_display_on_notif(dev);
-
- return (0);
}
static device_method_t acpi_spmc_methods[] = {
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -482,12 +482,14 @@
#define ACPI_EVENT_PRI_DEFAULT 10000
#define ACPI_EVENT_PRI_LAST 20000
-typedef void (*acpi_event_handler_t)(void *, int);
+typedef void (*acpi_event_handler_t)(void *, enum power_stype);
EVENTHANDLER_DECLARE(acpi_sleep_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_wakeup_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_acad_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_video_event, acpi_event_handler_t);
+EVENTHANDLER_DECLARE(acpi_late_suspend, acpi_event_handler_t);
+EVENTHANDLER_DECLARE(acpi_early_resume, acpi_event_handler_t);
/* Device power control. */
ACPI_STATUS acpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jun 12, 4:06 AM (9 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33899160
Default Alt Text
D48735.id170851.diff (4 KB)
Attached To
Mode
D48735: acpi: Call SPMC suspend/resume hooks
Attached
Detach File
Event Timeline
Log In to Comment