error-codes.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. ``-ENOSPC`` This request would overcommit the usb bandwidth reserved
  44. for periodic transfers (interrupt, isochronous).
  45. ``-ESHUTDOWN`` The device or host controller has been disabled due to
  46. some problem that could not be worked around.
  47. ``-EPERM`` Submission failed because ``urb->reject`` was set.
  48. ``-EHOSTUNREACH`` URB was rejected because the device is suspended.
  49. ``-ENOEXEC`` A control URB doesn't contain a Setup packet.
  50. ======================= =======================================================
  51. Error codes returned by ``in urb->status`` or in ``iso_frame_desc[n].status`` (for ISO)
  52. =======================================================================================
  53. USB device drivers may only test urb status values in completion handlers.
  54. This is because otherwise there would be a race between HCDs updating
  55. these values on one CPU, and device drivers testing them on another CPU.
  56. A transfer's actual_length may be positive even when an error has been
  57. reported. That's because transfers often involve several packets, so that
  58. one or more packets could finish before an error stops further endpoint I/O.
  59. For isochronous URBs, the urb status value is non-zero only if the URB is
  60. unlinked, the device is removed, the host controller is disabled, or the total
  61. transferred length is less than the requested length and the
  62. ``URB_SHORT_NOT_OK`` flag is set. Completion handlers for isochronous URBs
  63. should only see ``urb->status`` set to zero, ``-ENOENT``, ``-ECONNRESET``,
  64. ``-ESHUTDOWN``, or ``-EREMOTEIO``. Individual frame descriptor status fields
  65. may report more status codes.
  66. =============================== ===============================================
  67. 0 Transfer completed successfully
  68. ``-ENOENT`` URB was synchronously unlinked by
  69. :c:func:`usb_unlink_urb`
  70. ``-EINPROGRESS`` URB still pending, no results yet
  71. (That is, if drivers see this it's a bug.)
  72. ``-EPROTO`` [#f1]_, [#f2]_ a) bitstuff error
  73. b) no response packet received within the
  74. prescribed bus turn-around time
  75. c) unknown USB error
  76. ``-EILSEQ`` [#f1]_, [#f2]_ a) CRC mismatch
  77. b) no response packet received within the
  78. prescribed bus turn-around time
  79. c) unknown USB error
  80. Note that often the controller hardware does
  81. not distinguish among cases a), b), and c), so
  82. a driver cannot tell whether there was a
  83. protocol error, a failure to respond (often
  84. caused by device disconnect), or some other
  85. fault.
  86. ``-ETIME`` [#f2]_ No response packet received within the
  87. prescribed bus turn-around time. This error
  88. may instead be reported as
  89. ``-EPROTO`` or ``-EILSEQ``.
  90. ``-ETIMEDOUT`` Synchronous USB message functions use this code
  91. to indicate timeout expired before the transfer
  92. completed, and no other error was reported
  93. by HC.
  94. ``-EPIPE`` [#f2]_ Endpoint stalled. For non-control endpoints,
  95. reset this status with
  96. :c:func:`usb_clear_halt`.
  97. ``-ECOMM`` During an IN transfer, the host controller
  98. received data from an endpoint faster than it
  99. could be written to system memory
  100. ``-ENOSR`` During an OUT transfer, the host controller
  101. could not retrieve data from system memory fast
  102. enough to keep up with the USB data rate
  103. ``-EOVERFLOW`` [#f1]_ The amount of data returned by the endpoint was
  104. greater than either the max packet size of the
  105. endpoint or the remaining buffer size.
  106. "Babble".
  107. ``-EREMOTEIO`` The data read from the endpoint did not fill
  108. the specified buffer, and ``URB_SHORT_NOT_OK``
  109. was set in ``urb->transfer_flags``.
  110. ``-ENODEV`` Device was removed. Often preceded by a burst
  111. of other errors, since the hub driver doesn't
  112. detect device removal events immediately.
  113. ``-EXDEV`` ISO transfer only partially completed
  114. (only set in ``iso_frame_desc[n].status``,
  115. not ``urb->status``)
  116. ``-EINVAL`` ISO madness, if this happens: Log off and
  117. go home
  118. ``-ECONNRESET`` URB was asynchronously unlinked by
  119. :c:func:`usb_unlink_urb`
  120. ``-ESHUTDOWN`` The device or host controller has been
  121. disabled due to some problem that could not
  122. be worked around, such as a physical
  123. disconnect.
  124. =============================== ===============================================
  125. .. [#f1]
  126. Error codes like ``-EPROTO``, ``-EILSEQ`` and ``-EOVERFLOW`` normally
  127. indicate hardware problems such as bad devices (including firmware)
  128. or cables.
  129. .. [#f2]
  130. This is also one of several codes that different kinds of host
  131. controller use to indicate a transfer has failed because of device
  132. disconnect. In the interval before the hub driver starts disconnect
  133. processing, devices may receive such fault reports for every request.
  134. Error codes returned by usbcore-functions
  135. =========================================
  136. .. note:: expect also other submit and transfer status codes
  137. :c:func:`usb_register`:
  138. ======================= ===================================
  139. ``-EINVAL`` error during registering new driver
  140. ======================= ===================================
  141. ``usb_get_*/usb_set_*()``,
  142. :c:func:`usb_control_msg`,
  143. :c:func:`usb_bulk_msg()`:
  144. ======================= ==============================================
  145. ``-ETIMEDOUT`` Timeout expired before the transfer completed.
  146. ======================= ==============================================