summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/usb_pipe_drain_reqs.9f
blob: 9b8322e1b54080aac1834f4b24f873432b9f21c9 (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
'\" te
.\" Copyright (c) 2004, 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 USB_PIPE_DRAIN_REQS 9F "Jan 5, 2004"
.SH NAME
usb_pipe_drain_reqs \- Allow completion of pending pipe requests
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>



\fBint\fR \fBusb_pipe_drain_reqs\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_pipe_handle_t\fR \fIpipe_handle\fR,
     \fBuint_t\fR \fItimeout\fR, \fBusb_flags_t\fR \fIusb_flags\fR,
     \fBvoid (*\fR\fIcallback\fR)(usb_pipe_handle_t \fIpipe_handle\fR,
     \fBusb_opaque_t\fR \fIcallback_arg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags)\fR,
     \fBusb_opaque_t\fR \fIcallback_arg\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 16n
Pointer to the device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIpipe_handle\fR\fR
.ad
.RS 16n
Handle of the pipe containing pending requests.
.RE

.sp
.ne 2
.na
\fB\fItimeout\fR\fR
.ad
.RS 16n
Maximum wait time for requests to drain. Must be a non-negative value in
seconds. Zero specifies no timeout.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 16n
USB_FLAGS_SLEEP is the only flag recognized. Wait for completion and do not
call callback.
.RE

.sp
.ne 2
.na
\fB\fIcallback\fR\fR
.ad
.RS 16n
Callback handler to notify of asynchronous completion.
.RE

.sp
.ne 2
.na
\fB\fIcallback_arg\fR\fR
.ad
.RS 16n
Second argument passed to callback function.
.RE

.SH DESCRIPTION
The \fBusb_pipe_drain_reqs()\fR function provides waits for pending requests to
complete and then provides synchronous or asynchronous notification that all
pending requests on a non-shared pipe indicated by pipe_handle have completed.
For a shared pipe (such as the default control pipe used by multiple drivers
each managing one interface of a device), this function provides notification
that all pending requests on that pipe that are associated with a given dip are
completed.
.sp
.LP
The \fBusb_pipe_drain_reqs()\fR function can be used to notify a close
procedure when the default control pipe is clear during device closure, thereby
allowing the close procedure to continue safely. Normally, a synchronous call
to \fBusb_pipe_close\fR(9F) allows all requests in a pipe to finish before
returning. However, a client driver cannot close the default control pipe.
.sp
.LP
If USB_FLAGS_SLEEP is set in flags, block until all pending requests are
completed. Otherwise, return immediately and call the callback handler when all
pending requests are completed.
.sp
.LP
The \fIcallback\fR parameter accepts the asynchronous callback handler, which
takes the following arguments:
.sp
.ne 2
.na
\fBusb_pipe_handle_t default_pipe_handle\fR
.ad
.sp .6
.RS 4n
Handle of the pipe to drain.
.RE

.sp
.ne 2
.na
\fBusb_opaque_t callback_arg\fR
.ad
.sp .6
.RS 4n
callback_arg specified to \fBusb_pipe_drain_reqs()\fR.
.RE

.sp
.ne 2
.na
\fBint rval\fR
.ad
.sp .6
.RS 4n
Request status.
.RE

.sp
.ne 2
.na
\fBusb_cb_flags_t callback_flags\fR
.ad
.sp .6
.RS 4n
Status of the queueing operation. Can be:
.sp
.ne 2
.na
\fBUSB_CB_NO_INFO\fR
.ad
.RS 27n
Callback was uneventful.
.RE

.sp
.ne 2
.na
\fBUSB_CB_ASYNC_REQ_FAILED\fR
.ad
.RS 27n
Error starting asynchronous request.
.RE

.RE

.SH RETURN VALUES
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 23n
Request is successful.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_ARGS\fR
.ad
.RS 23n
\fIdip\fR argument is \fBNULL\fR. USB_FLAGS_SLEEP is clear and callback is
\fBNULL\fR.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_CONTEXT\fR
.ad
.RS 23n
Called from callback context with the USB_FLAGS_SLEEP flag set.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_PIPE\fR
.ad
.RS 23n
Pipe is not open, is closing or is closed.
.RE

.SH CONTEXT
May be called from user or kernel context.
.sp
.LP
If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if
supplied, can block because it is executing in kernel context. Otherwise the
callback cannot block. Please see \fBusb_callback_flags\fR(9S) for more
information on callbacks.
.SH EXAMPLES
.in +2
.nf
  mydev_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
 {

      ...
      ...

      mydev_state->pipe_state = CLOSED;

      /* Wait for pending requests of a pipe to finish.  Don't timeout. */
      (void) usb_pipe_drain_reqs(
          dip, pipe_handle, 0, USB_FLAGS_SLEEP, NULL, 0);

      /*
       * Dismantle streams and tear down this instance,
       * now that all requests have been sent.
       */
      qprocsoff(q);
      ...
      ...
      ddi_remove_minor_node(dip, NULL);
      ...
      ...
 }

.fi
.in -2

.SH NOTES
For pipes other than the default control pipe, it is recommended to close the
pipe using a synchronous \fBusb_pipe_close()\fR. \fBusb_pipe_close()\fR with
the USB_FLAGS_SLEEP flag allows any pending requests in that pipe to complete
before returning.
.sp
.LP
Do not call \fBusb_pipe_drain_reqs()\fR while additional requests are being
submitted by a different thread. This action can stall the calling thread of
\fBusb_pipe_drain_reqs()\fR unnecessarily.
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
.BR attributes (7),
.BR usb_pipe_close (9F),
.BR usb_pipe_reset (9F),
.BR usb_callback_flags (9S)