2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PM_RAISE_POWER 9F "Mar 22, 2005"
8 pm_raise_power, pm_lower_power \- Raise or lower power of components
13 #include <sys/sunddi.h>
15 \fBint\fR \fBpm_raise_power\fR(\fBdev_info_t *\fR\fIdip,\fR int \fIcomponent\fR, int \fIlevel\fR);
20 \fBint\fR \fBpm_lower_power\fR(\fBdev_info_t *\fR\fIdip,\fR int \fIcomponent\fR, int \fIlevel\fR);
26 Solaris DDI specific (Solaris DDI)
35 Pointer to the device's \fBdev_info\fR structure
44 The number of the \fIcomponent\fR for which a power level change is desired
53 The power level to which the indicated \fIcomponent\fR will be raised
63 Pointer to the device's \fBdev_info\fR structure
72 Number of the \fIcomponent\fR for which a power level change is desired
81 Power level to which the indicated \fIcomponent\fR will be lowered
87 The \fBpm_raise_power\fR(9F) function requests the Power Management framework
88 to raise the power level of \fIcomponent \fRof \fIdip\fR to at least \fIlevel.
92 The state of the device should be examined before each physical access. The
93 \fBpm_raise_power\fR(9F) function should be called to set a \fIcomponent \fR to
94 the required power level if the operation to be performed requires the
95 \fIcomponent \fR to be at a power level higher than its current power level.
98 When \fBpm_raise_power\fR(9F) returns with success, the \fIcomponent \fR is
99 guaranteed to be at least at the requested power level. All devices that depend
100 on this will be at their full power level. Since the actual device power level
101 may be higher than requested by the driver, the driver should not make any
102 assumption about the absolute power level on successful return from
103 \fBpm_raise_power\fR(9F).
106 The \fBpm_raise_power\fR(9F) function may cause re-entry of the driver
107 \fBpower\fR(9E) to raise the power level. Deadlock may result if the driver
108 locks are held across the call to \fBpm_raise_power\fR(9F).
111 The \fBpm_lower_power\fR(9F) function requests the Power Management framework
112 to lower the power level of \fIcomponent \fRof \fIdip\fR to at most
116 Normally, transitions to lower power levels are initiated by the Power
117 Management framework based on \fIcomponent\fR idleness. However, when
118 detaching, the driver should also initiate reduced power levels by setting the
119 power level of all device components to their lowest levels. The
120 \fBpm_lower_power\fR(9F) function is intended for this use only, and will
121 return \fBDDI_FAILURE\fR if the driver is not detaching at the time of the
125 If automatic Power Management is disabled (see \fBdtpower\fR(8) and
126 \fBpower.conf\fR(4)), \fBpm_lower_power\fR(9F) returns \fBDDI_SUCCESS\fR
127 without changing the power level of the component. Otherwise, when
128 \fBpm_lower_power\fR(9F) returns with success, the \fIcomponent \fR is
129 guaranteed to be at most at the requested power level. Since the actual device
130 power level may be lower than requested by the driver, the driver should not
131 make any assumption about the absolute power level on successful return from
132 \fBpm_lower_power\fR(9F).
135 The \fBpm_lower_power\fR(9F) function may cause re-entry of the driver
136 \fBpower\fR(9E) to lower the power level. Deadlock may result if the driver
137 locks are held across the call to \fBpm_lower_power\fR(9F).
142 If these functions are called as a result of entry into the driver's
143 \fBattach\fR(9E), \fBdetach\fR(9E) or \fBpower\fR(9E) entry point, these
144 functions must be called from the same thread which entered \fBattach\fR(9E),
145 \fBdetach\fR(9E) or \fBpower\fR(9E).
150 The \fBpm_raise_power\fR(9F) function returns:
154 \fB\fBDDI_SUCCESS\fR\fR
157 \fIComponent\fR is now at the requested power level or higher.
163 \fB\fBDDI_FAILURE\fR\fR
166 \fIComponent \fRor \fIlevel\fR is out of range, or the framework was unable to
167 raise the power level of the component to the requested level.
172 The \fBpm_lower_power\fR(9F) function returns:
176 \fB\fBDDI_SUCCESS\fR\fR
179 \fI Component \fR is now at the requested power level or lower, or automatic
180 Power Management is disabled.
186 \fB\fBDDI_FAILURE\fR\fR
189 \fI Component \fR or \fIlevel\fR is out of range, or the framework was unable
190 to lower the power level of the component to the requested level, or the device
197 A hypothetical disk driver might include this code to handle
198 \fBpm_raise_power\fR(9F):
203 xxdisk_strategy(struct buf *bp)
209 * At this point we have determined that we need to raise the
210 * power level of the device. Since we have to drop the
211 * mutex, we need to take care of case where framework is
212 * lowering power at the same time we are raising power.
213 * We resolve this by marking the device busy and failing
214 * lower power in power() entry point when device is busy.
217 ASSERT(mutex_owned(xsp->lock));
218 if (xsp->pm_busycnt < 1) {
220 * Component is not already marked busy
222 if (pm_busy_component(xsp->dip,
223 XXDISK_COMPONENT) != DDI_SUCCESS) {
230 mutex_exit(xsp->lock);
231 if (pm_raise_power(xsp->dip,
232 XXDISK_COMPONENT, XXPOWER_SPUN_UP) != DDI_SUCCESS) {
237 mutex_enter(xsp->lock);
244 xxdisk_power(dev_info *dip, int comp, int level)
250 * We fail the power() entry point if the device is busy and
251 * request is to lower the power level.
255 ASSERT(mutex_owned( xsp->lock));
256 if (xsp->pm_busycnt >= 1) {
257 if (level < xsp->cur_level) {
258 mutex_exit( xsp->lock);
259 return (DDI_FAILURE);
272 These functions can be called from user or kernel context.
276 See \fBattributes\fR(5) for a description of the following attribute:
284 ATTRIBUTE TYPE ATTRIBUTE VALUE
286 Interface stability Committed
292 \fBpower.conf\fR(4), \fBpm\fR(7D), \fBattach\fR(9E), \fBdetach\fR(9E),
293 \fBpower\fR(9E), \fBpm_busy_component\fR(9F), \fBpm_idle_component\fR(9F),
294 \fBpm\fR(9P), \fBpm-components\fR(9P)
297 \fIWriting Device Drivers\fR