Home | History | Annotate | Download | only in apm
History log of /src/sys/dev/apm/apm.c
RevisionDateAuthorComments
 1.35  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.34  19-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.33  28-Oct-2017  riastradh branches: 1.33.18;
Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.32  25-Oct-2017  maya Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.31  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.30  16-Mar-2014  dholland branches: 1.30.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.29  08-Nov-2013  christos fix unused variable
 1.28  30-Sep-2012  dsl branches: 1.28.2;
Remove code from dev/apm/apm.c for setting global variables to parameterise
the i386 bios apm code (now removed).
Remove the same code from the clone dev/hpc/apm/apmdev.c
Remove some not-used options from dev/apm/files.apm and the commented out
lines in ALL and GENERIC.
Maybe the APM_V10_ONLY and APM_NO_V12 could also be shot, but they are
further entwined in the code.
 1.27  17-Jul-2011  joerg branches: 1.27.2; 1.27.12;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.26  10-Mar-2010  bouyer Fix apm(4) suspend/resume:
- apm_suspend() and apm_standby() will call splhhigh() before entering
standby or suspend. After resume, the system go back tsleep()ing
in the apm thread without restoring the ipl (this is done in
apm_resume()), and calling tlseep() at IPL_HIGH cause a DIAGNOSTIC
panic (and other bad things, I guess).
Fix by calling apm_resume() from within apm_suspend() or apm_standby(),
after aa_set_powstate() has returned.
- In apm_event_handle(), we test (apm_standbys || apm_suspends) to set
apm_damn_fool_bios to 1 and break the while() loop in apm_periodic_check().
But we set apm_standbys or apm_suspends to non-0 only if apm_op_inprog
is 0 and we failed to record the apm event. With apmd listening
we usually succeed recording the event, so apm_standbys/apm_suspends remains
0 and we never go out of the while() loop.
Fix by apm_op_inprog instead of (apm_standbys || apm_suspends)
to break the loop.
 1.25  23-Nov-2009  rmind branches: 1.25.2;
Remove some unecessary includes sys/user.h header.
 1.24  16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.23  03-Apr-2009  uwe Treat OAPM_IOC_GETPOWER as APM_IOC_GETPOWER - from apmdev(4).
 1.22  12-Jun-2008  cegger branches: 1.22.4; 1.22.6; 1.22.10; 1.22.14;
use device_lookup_private to get softc
 1.21  28-Apr-2008  martin branches: 1.21.2; 1.21.4;
Remove clause 3 and 4 from TNF licenses
 1.20  12-Mar-2008  dyoung branches: 1.20.2; 1.20.4;
Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.19  07-Mar-2008  cube Split device_t/softc for i386's apm(4), and other related cosmetic changes.
 1.18  01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.17  04-Jan-2008  ad branches: 1.17.2; 1.17.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.16  09-Dec-2007  jmcneill branches: 1.16.2;
Merge jmcneill-pm branch.
 1.15  05-Dec-2007  pooka branches: 1.15.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.14  05-Dec-2007  ad lockmgr -> mutex
 1.13  25-Nov-2007  xtraeme branches: 1.13.2;
Do not run the get_powstat callback in apm_attach(), this has a bad
effect with coretemp(4) where it tries to run xc_unicast() before
the xc_thread is ready. Anyway the get_powstat callback was there only
for APM_POWER_PRINT, which will print the correct info if requested
later.
 1.12  09-Jul-2007  ad branches: 1.12.6; 1.12.8; 1.12.14;
warning: 'apm_create_thread' declared 'static' but never defined
 1.11  09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.10  04-Mar-2007  christos branches: 1.10.2; 1.10.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9  10-Dec-2006  uwe branches: 1.9.2;
Use aprint_normal for attachment messages.
 1.8  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.7  12-Oct-2006  xtraeme Use __unused in function arguments where appropiate. (hi christos)
 1.6  04-Oct-2006  dogcow add missing initializer element
 1.5  17-Jul-2006  christos branches: 1.5.4; 1.5.6;
make APM_POWER_PRINT compile.
 1.4  10-Jul-2006  christos fix some field names (Arnaud Lacombe)
 1.3  08-Jul-2006  christos Make apm an MI backend to be used by the i386 bios implementation and the
acpi implementation. Based on work by jmcneil.
 1.2  30-Jul-2000  takemura branches: 1.2.26; 1.2.36; 1.2.40; 1.2.42;
Remove src/sys/dev/apm/*. (They've gone to arch/hpcmips/dev/apm.)
 1.1  02-Jul-2000  takemura Common part of APM (advanced power management) support for Hpcmips.
 1.2.42.1  13-Jul-2006  gdamore Merge from HEAD.
 1.2.40.1  11-Aug-2006  yamt sync with head
 1.2.36.1  09-Sep-2006  rpaulo sync with head
 1.2.26.5  17-Mar-2008  yamt sync with head.
 1.2.26.4  21-Jan-2008  yamt sync with head
 1.2.26.3  07-Dec-2007  yamt sync with head
 1.2.26.2  03-Sep-2007  yamt sync with head.
 1.2.26.1  30-Dec-2006  yamt sync with head.
 1.5.6.2  10-Dec-2006  yamt sync with head.
 1.5.6.1  22-Oct-2006  yamt sync with head
 1.5.4.2  12-Jan-2007  ad Sync with head.
 1.5.4.1  18-Nov-2006  ad Sync with head.
 1.9.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.10.4.1  11-Jul-2007  mjf Sync with head.
 1.10.2.2  15-Jul-2007  ad Sync with head.
 1.10.2.1  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.12.14.3  18-Feb-2008  mjf Sync with HEAD.
 1.12.14.2  27-Dec-2007  mjf Sync with HEAD.
 1.12.14.1  08-Dec-2007  mjf Sync with HEAD.
 1.12.8.2  23-Mar-2008  matt sync with HEAD
 1.12.8.1  09-Jan-2008  matt sync with HEAD
 1.12.6.7  09-Dec-2007  jmcneill Sync with HEAD.
 1.12.6.6  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.12.6.5  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12.6.4  14-Nov-2007  joerg Introduce pnp_system_shutdown which just complains if drivers don't
support the PNP framework, give the user 2 seconds to worry about that
and runs the class and driver suspend functions. Keep all devices
powered e.g. to allow deciphering messages from the screen.
Drop the argument to pnp_system_suspend now that the use for it is gone.
 1.12.6.3  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.12.6.2  05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.12.6.1  04-Aug-2007  jmcneill dopowerhooks is going away; use pnp_global_transition instead
 1.13.2.2  26-Dec-2007  ad Sync with head.
 1.13.2.1  08-Dec-2007  ad Sync with head.
 1.15.2.1  11-Dec-2007  yamt sync with head.
 1.16.2.1  08-Jan-2008  bouyer Sync with HEAD
 1.17.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.17.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.17.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.17.2.1  24-Mar-2008  keiichi sync with head.
 1.20.4.4  11-Aug-2010  yamt sync with head.
 1.20.4.3  11-Mar-2010  yamt sync with head
 1.20.4.2  04-May-2009  yamt sync with head.
 1.20.4.1  16-May-2008  yamt sync with head.
 1.20.2.2  17-Jun-2008  yamt sync with head.
 1.20.2.1  18-May-2008  yamt sync with head.
 1.21.4.1  18-Jun-2008  simonb Sync with head.
 1.21.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.14.1  21-Apr-2010  matt sync to netbsd-5
 1.22.10.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.22.6.1  13-Mar-2010  riz Pull up following revision(s) (requested by bouyer in ticket #1337):
sys/dev/apm/apm.c: revision 1.26
Fix apm(4) suspend/resume:
- apm_suspend() and apm_standby() will call splhhigh() before entering
standby or suspend. After resume, the system go back tsleep()ing
in the apm thread without restoring the ipl (this is done in
apm_resume()), and calling tlseep() at IPL_HIGH cause a DIAGNOSTIC
panic (and other bad things, I guess).
Fix by calling apm_resume() from within apm_suspend() or apm_standby(),
after aa_set_powstate() has returned.
- In apm_event_handle(), we test (apm_standbys || apm_suspends) to set
apm_damn_fool_bios to 1 and break the while() loop in apm_periodic_check().
But we set apm_standbys or apm_suspends to non-0 only if apm_op_inprog
is 0 and we failed to record the apm event. With apmd listening
we usually succeed recording the event, so apm_standbys/apm_suspends remains
0 and we never go out of the while() loop.
Fix by apm_op_inprog instead of (apm_standbys || apm_suspends)
to break the loop.
 1.22.4.1  28-Apr-2009  skrll Sync with HEAD.
 1.25.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.27.12.3  03-Dec-2017  jdolecek update from HEAD
 1.27.12.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.12.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.27.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.2.1  30-Oct-2012  yamt sync with head
 1.28.2.1  18-May-2014  rmind sync with head
 1.30.2.1  10-Aug-2014  tls Rebase.
 1.33.18.1  03-Jan-2021  thorpej Sync w/ HEAD.

RSS XML Feed