summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/pm_raise_power.9f
blob: 30cd29462804be7651059f3f9c00398a695968a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
'\" te
.\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved
.\" 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.
.\" 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.
.\" 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]
.TH PM_RAISE_POWER 9F "Mar 22, 2005"
.SH NAME
pm_raise_power, pm_lower_power \- Raise or lower power of components
.SH SYNOPSIS
.nf
#include <sys/ddi.h>
#include <sys/sunddi.h>

\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
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.SS "pm_raise_power"
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 13n
Pointer to the device's \fBdev_info\fR structure
.RE

.sp
.ne 2
.na
\fB\fIcomponent\fR\fR
.ad
.RS 13n
The number of the \fIcomponent\fR for which a power level change is desired
.RE

.sp
.ne 2
.na
\fB\fIlevel\fR\fR
.ad
.RS 13n
The power level to which the indicated \fIcomponent\fR will be raised
.RE

.SS "pm_lower_power"
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 13n
Pointer to the device's \fBdev_info\fR structure
.RE

.sp
.ne 2
.na
\fB\fIcomponent\fR\fR
.ad
.RS 13n
Number of the \fIcomponent\fR for which a power level change is desired
.RE

.sp
.ne 2
.na
\fB\fIlevel\fR\fR
.ad
.RS 13n
Power level to which the indicated \fIcomponent\fR will be lowered
.RE

.SH DESCRIPTION
The \fBpm_raise_power\fR(9F) function requests the Power Management framework
to raise the power level of \fIcomponent \fRof \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 \fRof \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 (see \fBdtpower\fR(8) and
\fBpower.conf\fR(5)), \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
The \fBpm_raise_power\fR(9F) function returns:
.sp
.ne 2
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 15n
\fIComponent\fR is now at the requested power level or higher.
.RE

.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR\fR
.ad
.RS 15n
\fIComponent \fRor \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
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 15n
\fI Component \fR is now at the requested power level or lower, or automatic
Power Management is disabled.
.RE

.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR\fR
.ad
.RS 15n
\fI Component \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
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
These functions can be called from user or kernel context.
.SH ATTRIBUTES
See \fBattributes\fR(7) for a description of the following attribute:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface stability	Committed
.TE

.SH SEE ALSO
.BR pm (4D),
.BR power.conf (5),
.BR attach (9E),
.BR detach (9E),
.BR power (9E),
.BR pm_busy_component (9F),
.BR pm_idle_component (9F),
.BR pm (9P),
.BR pm-components (9P)
.sp
.LP
\fIWriting Device Drivers\fR