On system suspend, first get rid of the X server because it doesn't

respect the kernel device tree. (It is arguably ugly to special-case
wscons here, but as long as there is only one driver to be dealt with
it is not worth to introduce another set of hooks.)
Resume the X server at the end of resume, if everything went well.
Acquire the big KERNEL_LOCK before the device tree is walked on
suspend, until after the walk on resume. This is needed to avoid
device accesses by secondary CPUs, and it effectively keeps user
programs from interfering with the suspend process. This might be
revisited when all drivers are using private locks for MP-safeness
(but FreeBSD still does the same afaics).
It should be unnecessary now to switch secondary CPUs offline in
the powerd suspend script.
This commit is contained in:
drochner 2008-02-20 22:52:55 +00:00
parent 0c8d1e69b7
commit 6bc03e0cc0

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_pmf.c,v 1.11 2008/01/30 00:50:17 jmcneill Exp $ */
/* $NetBSD: kern_pmf.c,v 1.12 2008/02/20 22:52:55 drochner Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.11 2008/01/30 00:50:17 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.12 2008/02/20 22:52:55 drochner Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -48,6 +48,12 @@ __KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.11 2008/01/30 00:50:17 jmcneill Exp $
#include <sys/workqueue.h>
#include <prop/proplib.h>
/* XXX ugly special case, but for now the only client */
#include "wsdisplay.h"
#if NWSDISPLAY > 0
#include <dev/wscons/wsdisplayvar.h>
#endif
#ifdef PMF_DEBUG
int pmf_debug_event;
int pmf_debug_idle;
@ -214,6 +220,11 @@ pmf_system_resume(void)
}
aprint_debug(".\n");
KERNEL_UNLOCK_ONE(0);
#if NWSDISPLAY > 0
if (rv)
wsdisplay_handlex(1);
#endif
return rv;
}
@ -225,6 +236,11 @@ pmf_system_suspend(void)
if (!pmf_check_system_drivers())
return false;
#if NWSDISPLAY > 0
if (wsdisplay_handlex(0))
return false;
#endif
KERNEL_LOCK(1, 0);
/*
* Flush buffers only if the shutdown didn't do so