xref: /OK3568_Linux_fs/kernel/Documentation/driver-api/usb/error-codes.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. _usb-error-codes:
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunUSB Error codes
4*4882a593Smuzhiyun~~~~~~~~~~~~~~~
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun:Revised: 2004-Oct-21
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunThis is the documentation of (hopefully) all possible error codes (and
9*4882a593Smuzhiyuntheir interpretation) that can be returned from usbcore.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunSome of them are returned by the Host Controller Drivers (HCDs), which
12*4882a593Smuzhiyundevice drivers only see through usbcore.  As a rule, all the HCDs should
13*4882a593Smuzhiyunbehave the same except for transfer speed dependent behaviors and the
14*4882a593Smuzhiyunway certain faults are reported.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunError codes returned by :c:func:`usb_submit_urb`
18*4882a593Smuzhiyun================================================
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunNon-USB-specific:
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun=============== ===============================================
24*4882a593Smuzhiyun0		URB submission went fine
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun``-ENOMEM``	no memory for allocation of internal structures
27*4882a593Smuzhiyun=============== ===============================================
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunUSB-specific:
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun=======================	=======================================================
32*4882a593Smuzhiyun``-EBUSY``		The URB is already active.
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun``-ENODEV``		specified USB-device or bus doesn't exist
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun``-ENOENT``		specified interface or endpoint does not exist or
37*4882a593Smuzhiyun			is not enabled
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun``-ENXIO``		host controller driver does not support queuing of
40*4882a593Smuzhiyun			this type of urb.  (treat as a host controller bug.)
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun``-EINVAL``		a) Invalid transfer type specified (or not supported)
43*4882a593Smuzhiyun			b) Invalid or unsupported periodic transfer interval
44*4882a593Smuzhiyun			c) ISO: attempted to change transfer interval
45*4882a593Smuzhiyun			d) ISO: ``number_of_packets`` is < 0
46*4882a593Smuzhiyun			e) various other cases
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun``-EXDEV``		ISO: ``URB_ISO_ASAP`` wasn't specified and all the
49*4882a593Smuzhiyun			frames the URB would be scheduled in have already
50*4882a593Smuzhiyun			expired.
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun``-EFBIG``		Host controller driver can't schedule that many ISO
53*4882a593Smuzhiyun			frames.
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun``-EPIPE``		The pipe type specified in the URB doesn't match the
56*4882a593Smuzhiyun			endpoint's actual type.
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun``-EMSGSIZE``		(a) endpoint maxpacket size is zero; it is not usable
59*4882a593Smuzhiyun			    in the current interface altsetting.
60*4882a593Smuzhiyun			(b) ISO packet is larger than the endpoint maxpacket.
61*4882a593Smuzhiyun			(c) requested data transfer length is invalid: negative
62*4882a593Smuzhiyun			    or too large for the host controller.
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun``-ENOSPC``		This request would overcommit the usb bandwidth reserved
65*4882a593Smuzhiyun			for periodic transfers (interrupt, isochronous).
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun``-ESHUTDOWN``		The device or host controller has been disabled due to
68*4882a593Smuzhiyun			some problem that could not be worked around.
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun``-EPERM``		Submission failed because ``urb->reject`` was set.
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun``-EHOSTUNREACH``	URB was rejected because the device is suspended.
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun``-ENOEXEC``		A control URB doesn't contain a Setup packet.
75*4882a593Smuzhiyun=======================	=======================================================
76*4882a593Smuzhiyun
77*4882a593SmuzhiyunError codes returned by ``in urb->status`` or in ``iso_frame_desc[n].status`` (for ISO)
78*4882a593Smuzhiyun=======================================================================================
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunUSB device drivers may only test urb status values in completion handlers.
81*4882a593SmuzhiyunThis is because otherwise there would be a race between HCDs updating
82*4882a593Smuzhiyunthese values on one CPU, and device drivers testing them on another CPU.
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunA transfer's actual_length may be positive even when an error has been
85*4882a593Smuzhiyunreported.  That's because transfers often involve several packets, so that
86*4882a593Smuzhiyunone or more packets could finish before an error stops further endpoint I/O.
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunFor isochronous URBs, the urb status value is non-zero only if the URB is
89*4882a593Smuzhiyununlinked, the device is removed, the host controller is disabled, or the total
90*4882a593Smuzhiyuntransferred length is less than the requested length and the
91*4882a593Smuzhiyun``URB_SHORT_NOT_OK`` flag is set.  Completion handlers for isochronous URBs
92*4882a593Smuzhiyunshould only see ``urb->status`` set to zero, ``-ENOENT``, ``-ECONNRESET``,
93*4882a593Smuzhiyun``-ESHUTDOWN``, or ``-EREMOTEIO``. Individual frame descriptor status fields
94*4882a593Smuzhiyunmay report more status codes.
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun===============================	===============================================
98*4882a593Smuzhiyun0				Transfer completed successfully
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun``-ENOENT``			URB was synchronously unlinked by
101*4882a593Smuzhiyun				:c:func:`usb_unlink_urb`
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun``-EINPROGRESS``		URB still pending, no results yet
104*4882a593Smuzhiyun				(That is, if drivers see this it's a bug.)
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun``-EPROTO`` [#f1]_, [#f2]_	a) bitstuff error
107*4882a593Smuzhiyun				b) no response packet received within the
108*4882a593Smuzhiyun				   prescribed bus turn-around time
109*4882a593Smuzhiyun				c) unknown USB error
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun``-EILSEQ`` [#f1]_, [#f2]_	a) CRC mismatch
112*4882a593Smuzhiyun				b) no response packet received within the
113*4882a593Smuzhiyun				   prescribed bus turn-around time
114*4882a593Smuzhiyun				c) unknown USB error
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun				Note that often the controller hardware does
117*4882a593Smuzhiyun				not distinguish among cases a), b), and c), so
118*4882a593Smuzhiyun				a driver cannot tell whether there was a
119*4882a593Smuzhiyun				protocol error, a failure to respond (often
120*4882a593Smuzhiyun				caused by device disconnect), or some other
121*4882a593Smuzhiyun				fault.
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun``-ETIME`` [#f2]_		No response packet received within the
124*4882a593Smuzhiyun				prescribed bus turn-around time.  This error
125*4882a593Smuzhiyun				may instead be reported as
126*4882a593Smuzhiyun				``-EPROTO`` or ``-EILSEQ``.
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun``-ETIMEDOUT``			Synchronous USB message functions use this code
129*4882a593Smuzhiyun				to indicate timeout expired before the transfer
130*4882a593Smuzhiyun				completed, and no other error was reported
131*4882a593Smuzhiyun				by HC.
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun``-EPIPE`` [#f2]_		Endpoint stalled.  For non-control endpoints,
134*4882a593Smuzhiyun				reset this status with
135*4882a593Smuzhiyun				:c:func:`usb_clear_halt`.
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun``-ECOMM``			During an IN transfer, the host controller
138*4882a593Smuzhiyun				received data from an endpoint faster than it
139*4882a593Smuzhiyun				could be written to system memory
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun``-ENOSR``			During an OUT transfer, the host controller
142*4882a593Smuzhiyun				could not retrieve data from system memory fast
143*4882a593Smuzhiyun				enough to keep up with the USB data rate
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun``-EOVERFLOW`` [#f1]_		The amount of data returned by the endpoint was
146*4882a593Smuzhiyun				greater than either the max packet size of the
147*4882a593Smuzhiyun				endpoint or the remaining buffer size.
148*4882a593Smuzhiyun				"Babble".
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun``-EREMOTEIO``			The data read from the endpoint did not fill
151*4882a593Smuzhiyun				the specified buffer, and ``URB_SHORT_NOT_OK``
152*4882a593Smuzhiyun				was set in ``urb->transfer_flags``.
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun``-ENODEV``			Device was removed.  Often preceded by a burst
155*4882a593Smuzhiyun				of other errors, since the hub driver doesn't
156*4882a593Smuzhiyun				detect device removal events immediately.
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun``-EXDEV``			ISO transfer only partially completed
159*4882a593Smuzhiyun				(only set in ``iso_frame_desc[n].status``,
160*4882a593Smuzhiyun				not ``urb->status``)
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun``-EINVAL``			ISO madness, if this happens: Log off and
163*4882a593Smuzhiyun				go home
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun``-ECONNRESET``			URB was asynchronously unlinked by
166*4882a593Smuzhiyun				:c:func:`usb_unlink_urb`
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun``-ESHUTDOWN``			The device or host controller has been
169*4882a593Smuzhiyun				disabled due to some problem that could not
170*4882a593Smuzhiyun				be worked around, such as a physical
171*4882a593Smuzhiyun				disconnect.
172*4882a593Smuzhiyun===============================	===============================================
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun.. [#f1]
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun   Error codes like ``-EPROTO``, ``-EILSEQ`` and ``-EOVERFLOW`` normally
178*4882a593Smuzhiyun   indicate hardware problems such as bad devices (including firmware)
179*4882a593Smuzhiyun   or cables.
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun.. [#f2]
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun   This is also one of several codes that different kinds of host
184*4882a593Smuzhiyun   controller use to indicate a transfer has failed because of device
185*4882a593Smuzhiyun   disconnect.  In the interval before the hub driver starts disconnect
186*4882a593Smuzhiyun   processing, devices may receive such fault reports for every request.
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun
190*4882a593SmuzhiyunError codes returned by usbcore-functions
191*4882a593Smuzhiyun=========================================
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun.. note:: expect also other submit and transfer status codes
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun:c:func:`usb_register`:
196*4882a593Smuzhiyun
197*4882a593Smuzhiyun======================= ===================================
198*4882a593Smuzhiyun``-EINVAL``		error during registering new driver
199*4882a593Smuzhiyun======================= ===================================
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun``usb_get_*/usb_set_*()``,
202*4882a593Smuzhiyun:c:func:`usb_control_msg`,
203*4882a593Smuzhiyun:c:func:`usb_bulk_msg()`:
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun======================= ==============================================
206*4882a593Smuzhiyun``-ETIMEDOUT``		Timeout expired before the transfer completed.
207*4882a593Smuzhiyun======================= ==============================================
208