'\" te .\" Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. .TH pm_raise_power 9F "17 Mar 2015" "SunOS 5.11" "Kernel Functions for Drivers" .SH NAME pm_raise_power, pm_lower_power \- Raise or lower power of components .SH SYNOPSIS .LP .nf #include #include \fBint\fR \fBpm_raise_power\fR(\fBdev_info_t *\fR\fIdip,\fR int \fIcomponent\fR, int \fIlevel\fR); .fi .LP .nf \fBint\fR \fBpm_lower_power\fR(\fBdev_info_t *\fR\fIdip,\fR int \fIcomponent\fR, int \fIlevel\fR); .fi .SH INTERFACE LEVEL .sp .LP Solaris DDI specific (Solaris DDI) .SH PARAMETERS .SS "pm_raise_power" .sp .ne 2 .mk .na \fB\fIdip\fR\fR .ad .RS 13n .rt Pointer to the device's \fBdev_info\fR structure .RE .sp .ne 2 .mk .na \fB\fIcomponent\fR\fR .ad .RS 13n .rt The number of the \fIcomponent\fR for which a power level change is desired .RE .sp .ne 2 .mk .na \fB\fIlevel\fR\fR .ad .RS 13n .rt The power level to which the indicated \fIcomponent\fR will be raised .RE .SS "pm_lower_power" .sp .ne 2 .mk .na \fB\fIdip\fR\fR .ad .RS 13n .rt Pointer to the device's \fBdev_info\fR structure .RE .sp .ne 2 .mk .na \fB\fIcomponent\fR\fR .ad .RS 13n .rt Number of the \fIcomponent\fR for which a power level change is desired .RE .sp .ne 2 .mk .na \fB\fIlevel\fR\fR .ad .RS 13n .rt Power level to which the indicated \fIcomponent\fR will be lowered .RE .SH DESCRIPTION .sp .LP The \fBpm_raise_power\fR(9F) function requests the Power Management framework to raise the power level of \fIcomponent\fR of \fIdip\fR to at least \fIlevel\fR. .sp .LP The state of the device should be examined before each physical access. The \fBpm_raise_power\fR(9F) function should be called to set a \fIcomponent\fR to the required power level if the operation to be performed requires the \fIcomponent\fR to be at a power level higher than its current power level. .sp .LP When \fBpm_raise_power\fR(9F) returns with success, the \fIcomponent\fR is guaranteed to be at least at the requested power level. All devices that depend on this will be at their full power level. Since the actual device power level may be higher than requested by the driver, the driver should not make any assumption about the absolute power level on successful return from \fBpm_raise_power\fR(9F). .sp .LP The \fBpm_raise_power\fR(9F) function may cause re-entry of the driver \fBpower\fR(9E) to raise the power level. Deadlock may result if the driver locks are held across the call to \fBpm_raise_power\fR(9F). .sp .LP The \fBpm_lower_power\fR(9F) function requests the Power Management framework to lower the power level of \fIcomponent\fR of \fIdip\fR to at most \fIlevel\fR. .sp .LP Normally, transitions to lower power levels are initiated by the Power Management framework based on \fIcomponent\fR idleness. However, when detaching, the driver should also initiate reduced power levels by setting the power level of all device components to their lowest levels. The \fBpm_lower_power\fR(9F) function is intended for this use only, and will return \fBDDI_FAILURE\fR if the driver is not detaching at the time of the call. .sp .LP If automatic Power Management is disabled, \fBpm_lower_power\fR(9F) returns \fBDDI_SUCCESS\fR without changing the power level of the component. Otherwise, when \fBpm_lower_power\fR(9F) returns with success, the \fIcomponent\fR is guaranteed to be at most at the requested power level. Since the actual device power level may be lower than requested by the driver, the driver should not make any assumption about the absolute power level on successful return from \fBpm_lower_power\fR(9F). .sp .LP The \fBpm_lower_power\fR(9F) function may cause re-entry of the driver \fBpower\fR(9E) to lower the power level. Deadlock may result if the driver locks are held across the call to \fBpm_lower_power\fR(9F). .LP Note - .sp .RS 2 If these functions are called as a result of entry into the driver's \fBattach\fR(9E), \fBdetach\fR(9E) or \fBpower\fR(9E) entry point, these functions must be called from the same thread which entered \fBattach\fR(9E), \fBdetach\fR(9E) or \fBpower\fR(9E). .RE .SH RETURN VALUES .sp .LP The \fBpm_raise_power\fR(9F) function returns: .sp .ne 2 .mk .na \fB\fBDDI_SUCCESS\fR\fR .ad .RS 15n .rt \fIComponent\fR is now at the requested power level or higher. .RE .sp .ne 2 .mk .na \fB\fBDDI_FAILURE\fR\fR .ad .RS 15n .rt \fIComponent\fR or \fIlevel\fR is out of range, or the framework was unable to raise the power level of the component to the requested level. .RE .sp .LP The \fBpm_lower_power\fR(9F) function returns: .sp .ne 2 .mk .na \fB\fBDDI_SUCCESS\fR\fR .ad .RS 15n .rt \fIComponent\fR is now at the requested power level or lower, or automatic Power Management is disabled. .RE .sp .ne 2 .mk .na \fB\fBDDI_FAILURE\fR\fR .ad .RS 15n .rt \fIComponent\fR or \fIlevel\fR is out of range, or the framework was unable to lower the power level of the component to the requested level, or the device is not detaching. .RE .SH EXAMPLES .sp .LP A hypothetical disk driver might include this code to handle \fBpm_raise_power\fR(9F): .sp .in +2 .nf static int xxdisk_strategy(struct buf *bp) { ... /* * At this point we have determined that we need to raise the * power level of the device. Since we have to drop the * mutex, we need to take care of case where framework is * lowering power at the same time we are raising power. * We resolve this by marking the device busy and failing * lower power in power() entry point when device is busy. */ ASSERT(mutex_owned(xsp->lock)); if (xsp->pm_busycnt < 1) { /* * Component is not already marked busy */ if (pm_busy_component(xsp->dip, XXDISK_COMPONENT) != DDI_SUCCESS) { bioerror(bp,EIO); biodone(bp); return (0); } xsp->pm_busycnt++; } mutex_exit(xsp->lock); if (pm_raise_power(xsp->dip, XXDISK_COMPONENT, XXPOWER_SPUN_UP) != DDI_SUCCESS) { bioerror(bp,EIO); biodone(bp); return (0); } mutex_enter(xsp->lock); .... } xxdisk_power(dev_info *dip, int comp, int level) { \&... /* * We fail the power() entry point if the device is busy and * request is to lower the power level. */ ASSERT(mutex_owned( xsp->lock)); if (xsp->pm_busycnt >= 1) { if (level < xsp->cur_level) { mutex_exit( xsp->lock); return (DDI_FAILURE); } } \&... } .fi .in -2 .SH CONTEXT .sp .LP These functions can be called from user or kernel context. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for a description of the following attribute: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted .TE .SH SEE ALSO .sp .LP \fBpm\fR(7D), \fBattach\fR(9E), \fBdetach\fR(9E), \fBpower\fR(9E), \fBpm_busy_component\fR(9F), \fBpm_idle_component\fR(9F), \fBpm\fR(9P), \fBpm-components\fR(9P) .sp .LP \fIWriting Device Drivers for Oracle Solaris 11.2\fR