error-codes.rst 7.3 KB

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