Kernel Functions for Drivers pmpowerhaschanged(9F)
NAME
pmpowerhaschanged - Notify Power Management framework of
autonomous power level change
SYNOPSIS
#include
#include
int pmpowerhaschanged(devinfot *dip, int component, int level);
INTERFACE LEVEL
Solaris DI specific (Solaris DI)
PARAMETERS
dip Pointer to the device devinfo structure
component Number of the component that has changed power
level
level Power level to which the indicated component has
changed
DESCRIPTION
The pmpowerhaschanged(9) function notifies the Power
Management framework that the power level of component of
dip has changed to level.
Normally power level changes are initiated by the Power
Management framework due to device idleness, or through a
request to the framework from the driver via
pmraisepower(9F) or pmlowerpower(9F), but some devices
may change power levels on their own. For the framework to
track the power level of the device under these cir-
cumstances, the framework must be notified of autonomous
power level changes by a call to pmpowerhaschanged().
Because of the asynchronous nature of these events, the
Power Management framework might have called power(9E)
between the device's autonomous power level change and the
driver calling pmpowerhaschanged(), or the framework may
be in the process of changing the power level when
pmpowerhaschanged() is called. To handle these situations
correctly, the driver should verify that the device is
indeed at the level or set the device to the level if it
doesn't support inquirying of power levels, before calling
pmpowerhaschanged(). In addition, the driver should
SunOS 5.11 Last change: 22 July 2004 1
Kernel Functions for Drivers pmpowerhaschanged(9F)
prevent a power(9E) entry point from running in parallel
with pmpowerhaschanged().
Note -
If this function is called as a result of entry into the
driver's attach(9E), detach(9E) or power(9E) entry point,
this function must be called from the same thread which
entered attach(9E), detach(9E) or power(9E).
RETURN VALUES
The pmpowerhaschanged() function returns:
DISUCES The power level of component was successfully
updated to level.
DIFAILURE Invalid component component or power level
level.
CONTEXT
This function can be called from user or kernel context.
This function can also be called from interrupt context,
providing that it is not the first Power Management function
called by the driver.
EXAMPLES
A hypothetical driver might include this code to handle
pmpowerhaschanged(9):
static int
xxusbintr(struct buf *bp)
{
...
/*
* At this point the device has informed us that it has
* changed power level on its own. Inform this to framework.
* We need to take care of the case when framework has
* already called power() entry point and changed power level
* before we were able to inform framework of this change.
* Handle this by comparing the informed power level with
* the actual power level and only doing the call if they
* are same. In addition, make sure that power() doesn't get
* run in parallel with this code by holding the mutex.
*/
ASERT(mutexowned(&xsp->lock));
if (levelinformed == *(xsp->levelregaddr)) {
if (pmpowerhaschanged(xsp->dip, XUSBCOMPONENT,
SunOS 5.11 Last change: 22 July 2004 2
Kernel Functions for Drivers pmpowerhaschanged(9F)
levelinformed) != DISUCES) {
mutexexit( &xsp->lock);
return(DINTRUNCLAIMED);
}
}
....
}
xxdiskpower(devinfo *dip, int comp, int level)
{
mutexenter( xsp->lock);
...
...
}
ATRIBUTES
See attributes(5) for a description of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
SEE ALSO
power.conf(4), pm(7D), attach(9E), detach(9E), power(9E),
pmbusycomponent(9F), pmidlecomponent(9F),
pmraisepower(9F), pmlowerpower(9F), pm(9P), pm-
components(9P)
Writing Device Drivers
SunOS 5.11 Last change: 22 July 2004 3
|