xref: /openbmc/linux/Documentation/driver-api/usb/error-codes.rst (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1e1c3e6e1SMauro Carvalho Chehab.. _usb-error-codes:
2e1c3e6e1SMauro Carvalho Chehab
3360a7b5fSMauro Carvalho ChehabUSB Error codes
4360a7b5fSMauro Carvalho Chehab~~~~~~~~~~~~~~~
5360a7b5fSMauro Carvalho Chehab
6360a7b5fSMauro Carvalho Chehab:Revised: 2004-Oct-21
7360a7b5fSMauro Carvalho Chehab
8360a7b5fSMauro Carvalho ChehabThis is the documentation of (hopefully) all possible error codes (and
9360a7b5fSMauro Carvalho Chehabtheir interpretation) that can be returned from usbcore.
10360a7b5fSMauro Carvalho Chehab
11360a7b5fSMauro Carvalho ChehabSome of them are returned by the Host Controller Drivers (HCDs), which
12360a7b5fSMauro Carvalho Chehabdevice drivers only see through usbcore.  As a rule, all the HCDs should
13360a7b5fSMauro Carvalho Chehabbehave the same except for transfer speed dependent behaviors and the
14360a7b5fSMauro Carvalho Chehabway certain faults are reported.
15360a7b5fSMauro Carvalho Chehab
16360a7b5fSMauro Carvalho Chehab
17360a7b5fSMauro Carvalho ChehabError codes returned by :c:func:`usb_submit_urb`
18360a7b5fSMauro Carvalho Chehab================================================
19360a7b5fSMauro Carvalho Chehab
20360a7b5fSMauro Carvalho ChehabNon-USB-specific:
21360a7b5fSMauro Carvalho Chehab
22360a7b5fSMauro Carvalho Chehab
23360a7b5fSMauro Carvalho Chehab=============== ===============================================
24360a7b5fSMauro Carvalho Chehab0		URB submission went fine
25360a7b5fSMauro Carvalho Chehab
26360a7b5fSMauro Carvalho Chehab``-ENOMEM``	no memory for allocation of internal structures
27360a7b5fSMauro Carvalho Chehab=============== ===============================================
28360a7b5fSMauro Carvalho Chehab
29360a7b5fSMauro Carvalho ChehabUSB-specific:
30360a7b5fSMauro Carvalho Chehab
31360a7b5fSMauro Carvalho Chehab=======================	=======================================================
32360a7b5fSMauro Carvalho Chehab``-EBUSY``		The URB is already active.
33360a7b5fSMauro Carvalho Chehab
34360a7b5fSMauro Carvalho Chehab``-ENODEV``		specified USB-device or bus doesn't exist
35360a7b5fSMauro Carvalho Chehab
36360a7b5fSMauro Carvalho Chehab``-ENOENT``		specified interface or endpoint does not exist or
37360a7b5fSMauro Carvalho Chehab			is not enabled
38360a7b5fSMauro Carvalho Chehab
39360a7b5fSMauro Carvalho Chehab``-ENXIO``		host controller driver does not support queuing of
40360a7b5fSMauro Carvalho Chehab			this type of urb.  (treat as a host controller bug.)
41360a7b5fSMauro Carvalho Chehab
42360a7b5fSMauro Carvalho Chehab``-EINVAL``		a) Invalid transfer type specified (or not supported)
43360a7b5fSMauro Carvalho Chehab			b) Invalid or unsupported periodic transfer interval
44360a7b5fSMauro Carvalho Chehab			c) ISO: attempted to change transfer interval
45360a7b5fSMauro Carvalho Chehab			d) ISO: ``number_of_packets`` is < 0
46360a7b5fSMauro Carvalho Chehab			e) various other cases
47360a7b5fSMauro Carvalho Chehab
48360a7b5fSMauro Carvalho Chehab``-EXDEV``		ISO: ``URB_ISO_ASAP`` wasn't specified and all the
49360a7b5fSMauro Carvalho Chehab			frames the URB would be scheduled in have already
50360a7b5fSMauro Carvalho Chehab			expired.
51360a7b5fSMauro Carvalho Chehab
52360a7b5fSMauro Carvalho Chehab``-EFBIG``		Host controller driver can't schedule that many ISO
53360a7b5fSMauro Carvalho Chehab			frames.
54360a7b5fSMauro Carvalho Chehab
55360a7b5fSMauro Carvalho Chehab``-EPIPE``		The pipe type specified in the URB doesn't match the
56360a7b5fSMauro Carvalho Chehab			endpoint's actual type.
57360a7b5fSMauro Carvalho Chehab
58360a7b5fSMauro Carvalho Chehab``-EMSGSIZE``		(a) endpoint maxpacket size is zero; it is not usable
59360a7b5fSMauro Carvalho Chehab			    in the current interface altsetting.
60360a7b5fSMauro Carvalho Chehab			(b) ISO packet is larger than the endpoint maxpacket.
61360a7b5fSMauro Carvalho Chehab			(c) requested data transfer length is invalid: negative
62360a7b5fSMauro Carvalho Chehab			    or too large for the host controller.
63360a7b5fSMauro Carvalho Chehab
64*7652dd2cSAlan Stern``-EBADR``		The wLength value in a control URB's setup packet does
65*7652dd2cSAlan Stern			not match the URB's transfer_buffer_length.
66*7652dd2cSAlan Stern
67360a7b5fSMauro Carvalho Chehab``-ENOSPC``		This request would overcommit the usb bandwidth reserved
68360a7b5fSMauro Carvalho Chehab			for periodic transfers (interrupt, isochronous).
69360a7b5fSMauro Carvalho Chehab
70360a7b5fSMauro Carvalho Chehab``-ESHUTDOWN``		The device or host controller has been disabled due to
71360a7b5fSMauro Carvalho Chehab			some problem that could not be worked around.
72360a7b5fSMauro Carvalho Chehab
73360a7b5fSMauro Carvalho Chehab``-EPERM``		Submission failed because ``urb->reject`` was set.
74360a7b5fSMauro Carvalho Chehab
75360a7b5fSMauro Carvalho Chehab``-EHOSTUNREACH``	URB was rejected because the device is suspended.
76360a7b5fSMauro Carvalho Chehab
77360a7b5fSMauro Carvalho Chehab``-ENOEXEC``		A control URB doesn't contain a Setup packet.
78360a7b5fSMauro Carvalho Chehab=======================	=======================================================
79360a7b5fSMauro Carvalho Chehab
80360a7b5fSMauro Carvalho ChehabError codes returned by ``in urb->status`` or in ``iso_frame_desc[n].status`` (for ISO)
81360a7b5fSMauro Carvalho Chehab=======================================================================================
82360a7b5fSMauro Carvalho Chehab
83360a7b5fSMauro Carvalho ChehabUSB device drivers may only test urb status values in completion handlers.
84360a7b5fSMauro Carvalho ChehabThis is because otherwise there would be a race between HCDs updating
85360a7b5fSMauro Carvalho Chehabthese values on one CPU, and device drivers testing them on another CPU.
86360a7b5fSMauro Carvalho Chehab
87360a7b5fSMauro Carvalho ChehabA transfer's actual_length may be positive even when an error has been
88360a7b5fSMauro Carvalho Chehabreported.  That's because transfers often involve several packets, so that
89360a7b5fSMauro Carvalho Chehabone or more packets could finish before an error stops further endpoint I/O.
90360a7b5fSMauro Carvalho Chehab
91360a7b5fSMauro Carvalho ChehabFor isochronous URBs, the urb status value is non-zero only if the URB is
92360a7b5fSMauro Carvalho Chehabunlinked, the device is removed, the host controller is disabled, or the total
93360a7b5fSMauro Carvalho Chehabtransferred length is less than the requested length and the
94360a7b5fSMauro Carvalho Chehab``URB_SHORT_NOT_OK`` flag is set.  Completion handlers for isochronous URBs
95360a7b5fSMauro Carvalho Chehabshould only see ``urb->status`` set to zero, ``-ENOENT``, ``-ECONNRESET``,
96360a7b5fSMauro Carvalho Chehab``-ESHUTDOWN``, or ``-EREMOTEIO``. Individual frame descriptor status fields
97360a7b5fSMauro Carvalho Chehabmay report more status codes.
98360a7b5fSMauro Carvalho Chehab
99360a7b5fSMauro Carvalho Chehab
100360a7b5fSMauro Carvalho Chehab===============================	===============================================
101360a7b5fSMauro Carvalho Chehab0				Transfer completed successfully
102360a7b5fSMauro Carvalho Chehab
103360a7b5fSMauro Carvalho Chehab``-ENOENT``			URB was synchronously unlinked by
104360a7b5fSMauro Carvalho Chehab				:c:func:`usb_unlink_urb`
105360a7b5fSMauro Carvalho Chehab
106360a7b5fSMauro Carvalho Chehab``-EINPROGRESS``		URB still pending, no results yet
107360a7b5fSMauro Carvalho Chehab				(That is, if drivers see this it's a bug.)
108360a7b5fSMauro Carvalho Chehab
109360a7b5fSMauro Carvalho Chehab``-EPROTO`` [#f1]_, [#f2]_	a) bitstuff error
110360a7b5fSMauro Carvalho Chehab				b) no response packet received within the
111360a7b5fSMauro Carvalho Chehab				   prescribed bus turn-around time
112360a7b5fSMauro Carvalho Chehab				c) unknown USB error
113360a7b5fSMauro Carvalho Chehab
114360a7b5fSMauro Carvalho Chehab``-EILSEQ`` [#f1]_, [#f2]_	a) CRC mismatch
115360a7b5fSMauro Carvalho Chehab				b) no response packet received within the
116360a7b5fSMauro Carvalho Chehab				   prescribed bus turn-around time
117360a7b5fSMauro Carvalho Chehab				c) unknown USB error
118360a7b5fSMauro Carvalho Chehab
119360a7b5fSMauro Carvalho Chehab				Note that often the controller hardware does
120360a7b5fSMauro Carvalho Chehab				not distinguish among cases a), b), and c), so
121360a7b5fSMauro Carvalho Chehab				a driver cannot tell whether there was a
122360a7b5fSMauro Carvalho Chehab				protocol error, a failure to respond (often
123360a7b5fSMauro Carvalho Chehab				caused by device disconnect), or some other
124360a7b5fSMauro Carvalho Chehab				fault.
125360a7b5fSMauro Carvalho Chehab
126360a7b5fSMauro Carvalho Chehab``-ETIME`` [#f2]_		No response packet received within the
127360a7b5fSMauro Carvalho Chehab				prescribed bus turn-around time.  This error
128360a7b5fSMauro Carvalho Chehab				may instead be reported as
129360a7b5fSMauro Carvalho Chehab				``-EPROTO`` or ``-EILSEQ``.
130360a7b5fSMauro Carvalho Chehab
131360a7b5fSMauro Carvalho Chehab``-ETIMEDOUT``			Synchronous USB message functions use this code
132360a7b5fSMauro Carvalho Chehab				to indicate timeout expired before the transfer
133360a7b5fSMauro Carvalho Chehab				completed, and no other error was reported
134360a7b5fSMauro Carvalho Chehab				by HC.
135360a7b5fSMauro Carvalho Chehab
136360a7b5fSMauro Carvalho Chehab``-EPIPE`` [#f2]_		Endpoint stalled.  For non-control endpoints,
137360a7b5fSMauro Carvalho Chehab				reset this status with
138360a7b5fSMauro Carvalho Chehab				:c:func:`usb_clear_halt`.
139360a7b5fSMauro Carvalho Chehab
140360a7b5fSMauro Carvalho Chehab``-ECOMM``			During an IN transfer, the host controller
141360a7b5fSMauro Carvalho Chehab				received data from an endpoint faster than it
142360a7b5fSMauro Carvalho Chehab				could be written to system memory
143360a7b5fSMauro Carvalho Chehab
144360a7b5fSMauro Carvalho Chehab``-ENOSR``			During an OUT transfer, the host controller
145360a7b5fSMauro Carvalho Chehab				could not retrieve data from system memory fast
146360a7b5fSMauro Carvalho Chehab				enough to keep up with the USB data rate
147360a7b5fSMauro Carvalho Chehab
148360a7b5fSMauro Carvalho Chehab``-EOVERFLOW`` [#f1]_		The amount of data returned by the endpoint was
149360a7b5fSMauro Carvalho Chehab				greater than either the max packet size of the
150360a7b5fSMauro Carvalho Chehab				endpoint or the remaining buffer size.
151360a7b5fSMauro Carvalho Chehab				"Babble".
152360a7b5fSMauro Carvalho Chehab
153360a7b5fSMauro Carvalho Chehab``-EREMOTEIO``			The data read from the endpoint did not fill
154360a7b5fSMauro Carvalho Chehab				the specified buffer, and ``URB_SHORT_NOT_OK``
155360a7b5fSMauro Carvalho Chehab				was set in ``urb->transfer_flags``.
156360a7b5fSMauro Carvalho Chehab
157360a7b5fSMauro Carvalho Chehab``-ENODEV``			Device was removed.  Often preceded by a burst
158360a7b5fSMauro Carvalho Chehab				of other errors, since the hub driver doesn't
159360a7b5fSMauro Carvalho Chehab				detect device removal events immediately.
160360a7b5fSMauro Carvalho Chehab
161360a7b5fSMauro Carvalho Chehab``-EXDEV``			ISO transfer only partially completed
162360a7b5fSMauro Carvalho Chehab				(only set in ``iso_frame_desc[n].status``,
163360a7b5fSMauro Carvalho Chehab				not ``urb->status``)
164360a7b5fSMauro Carvalho Chehab
165360a7b5fSMauro Carvalho Chehab``-EINVAL``			ISO madness, if this happens: Log off and
166360a7b5fSMauro Carvalho Chehab				go home
167360a7b5fSMauro Carvalho Chehab
168360a7b5fSMauro Carvalho Chehab``-ECONNRESET``			URB was asynchronously unlinked by
169360a7b5fSMauro Carvalho Chehab				:c:func:`usb_unlink_urb`
170360a7b5fSMauro Carvalho Chehab
171360a7b5fSMauro Carvalho Chehab``-ESHUTDOWN``			The device or host controller has been
172360a7b5fSMauro Carvalho Chehab				disabled due to some problem that could not
173360a7b5fSMauro Carvalho Chehab				be worked around, such as a physical
174360a7b5fSMauro Carvalho Chehab				disconnect.
175360a7b5fSMauro Carvalho Chehab===============================	===============================================
176360a7b5fSMauro Carvalho Chehab
177360a7b5fSMauro Carvalho Chehab
178360a7b5fSMauro Carvalho Chehab.. [#f1]
179360a7b5fSMauro Carvalho Chehab
180360a7b5fSMauro Carvalho Chehab   Error codes like ``-EPROTO``, ``-EILSEQ`` and ``-EOVERFLOW`` normally
181360a7b5fSMauro Carvalho Chehab   indicate hardware problems such as bad devices (including firmware)
182360a7b5fSMauro Carvalho Chehab   or cables.
183360a7b5fSMauro Carvalho Chehab
184360a7b5fSMauro Carvalho Chehab.. [#f2]
185360a7b5fSMauro Carvalho Chehab
186360a7b5fSMauro Carvalho Chehab   This is also one of several codes that different kinds of host
187360a7b5fSMauro Carvalho Chehab   controller use to indicate a transfer has failed because of device
188360a7b5fSMauro Carvalho Chehab   disconnect.  In the interval before the hub driver starts disconnect
189360a7b5fSMauro Carvalho Chehab   processing, devices may receive such fault reports for every request.
190360a7b5fSMauro Carvalho Chehab
191360a7b5fSMauro Carvalho Chehab
192360a7b5fSMauro Carvalho Chehab
193360a7b5fSMauro Carvalho ChehabError codes returned by usbcore-functions
194360a7b5fSMauro Carvalho Chehab=========================================
195360a7b5fSMauro Carvalho Chehab
196360a7b5fSMauro Carvalho Chehab.. note:: expect also other submit and transfer status codes
197360a7b5fSMauro Carvalho Chehab
198360a7b5fSMauro Carvalho Chehab:c:func:`usb_register`:
199360a7b5fSMauro Carvalho Chehab
200360a7b5fSMauro Carvalho Chehab======================= ===================================
201360a7b5fSMauro Carvalho Chehab``-EINVAL``		error during registering new driver
202360a7b5fSMauro Carvalho Chehab======================= ===================================
203360a7b5fSMauro Carvalho Chehab
204360a7b5fSMauro Carvalho Chehab``usb_get_*/usb_set_*()``,
205360a7b5fSMauro Carvalho Chehab:c:func:`usb_control_msg`,
206360a7b5fSMauro Carvalho Chehab:c:func:`usb_bulk_msg()`:
207360a7b5fSMauro Carvalho Chehab
208360a7b5fSMauro Carvalho Chehab======================= ==============================================
209360a7b5fSMauro Carvalho Chehab``-ETIMEDOUT``		Timeout expired before the transfer completed.
210360a7b5fSMauro Carvalho Chehab======================= ==============================================
211