History log of /fuchsia/zircon/system/dev/usb/xhci/xhci-transfer.c
Revision Date Author Comments
# 42000010 27-Sep-2018 David Stevens <stevensd@google.com>

[xhci] Prevent crash from transfers after stopping

xhci_stop_endpoint releases the transfer ring, so make sure we don't
try to access it in xhci_handle_transfer_event. Stopping an endpoint
completes any queued/pending requests, so skipping them when handling
transfer events is fine.

Test: Repeatedly stop/start video_display w/a usb video capture device.
Change-Id: I0460759fa0373c749fcac91f1d773dbfc71ced5c


# 79c8b30e 26-Sep-2018 Ruchira Ravoori <ravoorir@google.com>

[zircon][usb-request-cleanup]Remove bti_handle from usb-request

The bti_handle is used only during the physmap which is used only at the
usb infrastructure level and not by the client drivers. This change removes
the bti handle from usb_request_t, and also removes the need for it beeing needed
during the usb_request_alloc. In a later changeset, clients will be using
the usb_request_alloc directly from the usb-request library and not via
the protocol op. This changeset is in preparation for that to work.

Test: Full build. Netbooting on vim2. Plugged in a usb-mass-storage
device and verified lsusb works as expected.

Change-Id: I158917a9cfec1c3b0f2b9ec905c17dbfcc6ecbc7


# 5f162810 01-Aug-2018 Ruchira Ravoori <ravoorir@google.com>

[zircon][xhci] Reduce log spew when usb device is removed

This changeset aims at reducing the log spew. In the case we do not find
a request to complete for a trb we silently quit handling the TRB.

Test: fx full-build. Sanity test on pixelbook.

NET-1233 #comment Reduce xhci logging

Change-Id: I3ab7fc15863684ce1e7b018bcd24805e4170a0d2


# babe1cf5 25-Jul-2018 Adam Barth <abarth@chromium.org>

[sync] Apply C API rubric to libsync

Test: No behavior change
Change-Id: I30a413f7fb5d3f4e741e5204532b82e73595c086


# a23f7534 01-May-2018 Jocelyn Dang <jocelyndang@google.com>

[dev][usb-xhci] Move usb_request_physmap call out of
xhci_transfer_state_init.

It would be easier to not have to deal with the invalid requests list
populated in xdc_process_transactions_locked (will be called in more
places soon).

The only way it fails is if the physmap fails,
so we call that in xdc_queue_transfer to weed out bad requests upfront

Change-Id: I318e67343f4e95fea949b25dd4f914252d0d2405


# 7837c25b 19-Apr-2018 Ruchira Ravoori <ravoorir@rodete-desktop-imager.corp.google.com>

[zircon][xhci] Initialize TT fields for all the low/full speed devices

The transaction translator fields should be set for all the low/full
speed devices. Currently our code only sets it if the parent is a high
speed hub and does not pass on the TT fields to children of a full speed
or a low speed hub which is connected to a high speed hub. Without this,
the xhc generates errors for the SET_ADDRESS command and the device does
not initialize properly. This changeset does the following:
1. Passes on the TT fields as required.
2. Add a sleep between Address Device and Get Descriptor commands.
Without this, the Get Descriptor command fails on Razer Megalogon headset.
3. Provides error handling for legacy devices that might expect Get
Descriptor request before SET_ADDRESS request.
ZX-1933 #done ZX-1975 #done

Change-Id: I80045a2569ba108f697034dd8c85229a8960bea9


# 82716ef6 18-Apr-2018 Jocelyn Dang <jocelyndang@google.com>

[dev][usb-xhci] Extract initialization of xhci_transfer_state to
new function.

Also for debug cap use.

Change-Id: Iaf13a5111fe251d49c766c495571ee536daaf206


# aa213037 18-Apr-2018 Jocelyn Dang <jocelyndang@google.com>

[dev][usb-xhci] Extract data stage of usb transfer to
xhci-transfer-common.

Also moves print_trb and the xhci_transfer_state struct.

We need almost the same code for the debug cap bulk transfers
so figured it would be nice not to duplicate.

Change-Id: If62b0ec10c2ec84f5a8f75c8f3633b256d7fe091


# af71cbda 06-Apr-2018 Mike Voydanoff <voydanoff@google.com>

[dev][usb] Add support for automatic zero length packets

Set send_zlp flag on usb_request_t if you want zero length packets
sent automatically when transfer length is a multiple of max packet size.

ZX-1952 #done

Change-Id: I78e1cf3231179ec77b20b1ca95e5b765e7ed5dac


# 54dc7146 26-Mar-2018 Ruchira Ravoori <ravoorir@rodete-desktop-imager.corp.google.com>

[zircon][xhci][usb-cdc]Add a delay between requests when TRB Error occurs

When downloading files from the target using some of the usb-c ethernet adapters that use
usb-cdc-ecm driver, the scp loses connection intermittently and will not work until a reboot.
The underlying reason is that the device is not able to match the pace of the requests from
client driver. When this happens, the xhc controller converts the NRDY packets on the bus to
TRB Error. There is no way we can further know what the reason for TRB Error and it can be
other things too. So we do the normal reset deque ptr when we see a TRB Error, but we also
introduce a delay between the requests to slow down the I/O. There is a likely chance that
we might need to increase the delays as the situation arises.
NET-97 #done

Change-Id: Id06022e5a7b0129419b2768e37ec61daaa2df368


# 79b69447 14-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][usb-request] Remove obsolete non-BTI USB request allocators

And rename the new ones to remove the "_with_bti"

Change-Id: If34be2e86645e463636ff606ef95cb99b48ac3fa


# fe48d46b 14-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[dev][usb] Switch to new USB request allocator protocol

This is needed to allow using BTIs for USB request buffers

Change-Id: I349fec2cbfb525c2dd910986dcb3b4a4c28b36e1


# 53d75781 23-Jan-2018 Jocelyn Dang <jocelyndang@google.com>

[dev][usb-xhci] Move CLEAR_FEATURE(ENDPOINT_HALT) request to after
the Reset Endpoint Command.

NET-97 #comment

Change-Id: Ic9d926cbc01efb31d525c2776d28f931e0dd424a


# df9b0a8c 11-Jan-2018 Ruchira Ravoori <ravoorir@ravoorir.mtv.corp.google.com>

[XHCI] Resolve potential deadlock when resetting an endpoint ZX-1560 #done

Change-Id: I4c44b9082c2a3949ac040cc270da278b79cf8b47


# 39975c50 16-Jan-2018 Ruchira Ravoori <ravoorir@ravoorir.mtv.corp.google.com>

Do not queue more transfers when endpoint is in paused state. We are in the midst of cancelling all the transfers. The comment in xhci_cancel_transfers talks about the same.

Change-Id: I6c0bed66c33c65fb2f73d0116b0ea2e3c8c14c63


# c4ebc01f 16-Jan-2018 Jocelyn Dang <jocelyndang@google.com>

[dev][usb-xhci] Differentiate between empty and full trb transfer rings.

When ring->current == ring->dequeue_ptr, we would always return 255
(empty ring), but if we enqueue really large requests, ring->current
may loop back around and we should return 0.

Change-Id: Ifeb903f032569f296cdff98881800c8e05598a28


# 4384fb84 18-Nov-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb][xhci] Handle stalls in the status phase of a control requests

Some devices (like the Schitt Fulla 2 audio interface) will report success
during the data phase of a control request but then issue a stall during
the status phase. Previously we were completing the request when we receive
the transfer event corresponding to the data phase. Later when we receive
the stall event for the status phase it is too late to report this back to
the client.

To fix this we now set the IOC bit on the status TRB so we now receive
a transfer event for both the setup or data phase and the status phase.
When we receive the first transfer event we record the result in the
USB request, but defer completing that request until we receive the
transfer event for the status phase. At that point we update the
USB request's result status if necessary and then complete the request.

ZX_1375 #comment in progress

Change-Id: Ib7a1c4164f0ecf09b75735293aa1985465cd2a4b


# c92e74a1 16-Nov-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb][xhci] Use zx_cache_flush instead of zx_vmo_op_range for cache management

Change-Id: I261246de12f4c915b485dfb15830d084658e9ffc


# f4b2ff04 23-Oct-2017 Brian Swetland <swetland@google.com>

[ddk] rename dprintf() to zxlogf() to avoid conflicts

dprintf is still defined by ddk/debug.h but with a deprecation warning

Change-Id: I00b34803571c468007e069c1da6a292feba2bc3c


# 7ca7be57 04-Oct-2017 Jocelyn Dang <jocelyndang@google.com>

[dev][usb] Migrate xhci to usb_request.

Change-Id: Ifd0ceb3f033d530e70c88fc80321cf9fc0be8f40


# f9c49386 16-Oct-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] Move some root hub related dprintfs from TRACE to SPEW

Printing out the emulated root hub control request traffic clutters
up the log when doing XHCI bring-up work.

Change-Id: I4f7988bbf97064adbe566e10e72a4d2735f9679c


# a18aea8b 15-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb][xhci] Clean and invalidate caches as necessary on non-x86 platforms

Also made VMOs for event rings and device contexts read-only

Change-Id: I1aee51c7ba4515523219826fc0b013d6771e514b


# dacc1d80 12-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev] Rename "mxdev" to "zxdev" in ddktl and various drivers.

Change-Id: I000e42c26d9f8379de40447690694a35f6be93e2


# f3e2126c 12-Sep-2017 Roland McGrath <mcgrathr@google.com>

[zx] Magenta -> Zircon

The Great Renaming is here!

Change-Id: I3229bdeb2a3d0e40fb4db6fec8ca7d971fbffb94


# bc6afa00 07-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev][xhci] Switch to new DDK dprintf() logging calls

Change-Id: I629e2b486de24749fb217e63d4ca40cb39b14390


# 12ba0f22 29-Aug-2017 Jocelyn Dang <jocelyndang@google.com>

[usb-xhci] Fix issue with sending zero length packets to a bulk endpoint.

The spec doesn't allow consecutive event data TRBs on a transfer ring.
Adding an extra zero length transfer TRB seems to make it happy.

MG-1026 #done

Change-Id: I5be9e40fc40d4f2f6243192b71e5d30715774b2d


# c78371bd 28-Aug-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] Fix problem with iotxns getting lost after resetting an endpoint

xhci_reset_endpoint() calls xhci_reset_dequeue_ptr_locked(), which moves
the endpoint's transfer ring dequeue pointer past the last transaction in the
transfer ring. In the case where we reset an endpoint that has had multiple iotxns
queued, we now complete move all pending iotxns back to the queued iotxns list
so they will be restarted when the endpoint is reset.

I think this should fix MG-1054

Change-Id: I3b57629f4d0411abd6477755984b8baf9c3ee5c1


# 0ab8844d 26-Jul-2017 Jocelyn Dang <jocelyndang@google.com>

[usb][xhci] Use two interrupts / completers, isoch transfers are sent to
HIGH_PRIORITY thread.

MG-937 #comment

Change-Id: Ibaa2eb3c2fea12164d141966ef8f18d48688ccf1


# d07baedb 30-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[usb] add support for canceling and timing out transactions

Added usb_cancel_all() to the USB protocol, which cancels all
pending iotxns on an endpoint.

The "timeout" parameter to usb_control() is now being honored.

Also replaced the "enabled", "halted" and endpoint flags with
a new xhci_ep_state_t enum.

To avoid confusion, the endpoint state in the hardware's endpoint context
has been renamed from EP_STATE_* to EP_CTX_STATE_* and the accessor
has been renamed to xhci_get_ep_ctx_state()

Change-Id: Id4daafc88c4767e8723deeed373b5321440469b9


# 0dd96c32 02-Aug-2017 Jocelyn Dang <jocelyndang@google.com>

[xhci] Fix interruptor typo

Change-Id: I325b8d492ea4b30acd08330173968f979fc8be05


# 5978f38e 13-Jul-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] Fix list corruption bug in error handling path

When xhci_continue_transfer_locked() returned an error, we were not
removing the iotxn from the pending_txns list before adding it to completed_txns.
This resulted in eventual disaster after seeing
"can't schedule transfer into the past" errors when isochronous transfers
failed to make their frame deadlines.

This might fix MG-920

Change-Id: I76d6e8b82b3df6d48edafd0a071ee8fd7817d0fd


# a5f1bef5 29-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[usb] Revert changes related to canceling USB transactions

These changes introduced a number of bugs and need more work.

Squashed commit of:

Revert "[usb] add support for canceling and timing out transactions"

This reverts commit b986f57f0d5776585086d1eb6a99d65cdcff2486.

Revert "[dev][usb-xhci] Endpoint state cleanup work"

This reverts commit 5d8c3e1594c0f8161c1e2ca8e80533d0e83f5c8e.

Revert "[dev][usb-xhci] Cleanup completing transactions when stopping an endpoint"

This reverts commit cdbc4364957bc9c3067caba54adfb73fae887f03.

Change-Id: I1ab9ba1fbc06ba9e992ec71bb41ecf2465e72e29


# b986f57f 29-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[usb] add support for canceling and timing out transactions

Added iotxn_cancel() to the USB protocol, which can be used to cancel pending iotxns.

usb_control() will now return MX_ERR_TIMED_OUT if hardware does not respond
within 5 seconds.

Change-Id: I9146ad88435140f7fca4be0aeeea11bbb5f7eb55


# 5d8c3e15 28-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] Endpoint state cleanup work

Replace the "enabled", "halted" and "stopped_reason" endpoint flags with
a new xhci_ep_state_t enum.

To avoid confusion, the endpoint state in the hardware's endpoint context
has been renamed from EP_STATE_* to EP_CTX_STATE_* and the accessor
has been renamed to xhci_get_ep_ctx_state()

Change-Id: I195d688948d4ca65db395205e35f52145893d400


# cdbc4364 28-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] Cleanup completing transactions when stopping an endpoint

The XHCI "stop endpoint" command will complete all pending transfers
before the command completes. We now take advantage of that by allowing
them to complete normally rather than completing them xhci_stop_endpoint()
and ignoring the transfer events in xhci_handle_transfer_event().

This is prep work for adding support for cancelling transfers.

Change-Id: Ibc5858ec291c65b0cdd580c17a22bcb66424e1c0


# 7f28ef5a 27-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Error reporting improvements:

Babble errors are now reported as MX_ERR_IO_OVERRUN and missed service errors
for isochronous transfers are now reported as MX_ERR_IO_MISSED_DEADLINE.

Change-Id: I84c482fb82931794cfcae9b4b35889eb9ba23864


# 849dff9c 26-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Improve handling of stalled and errored endpoints

Change-Id: I9c7ff28fa5b60db80cd3145323753037515ebf33


# 8eab60a9 23-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Return MX_ERR_IO_REFUSED when in state EP_STATE_STOPPED

usb_reset_endpoint() can recover when in this state too, and this fixes a
problem introduced in the previous change for the code that recovers from
stalls when reading the device descriptor during device enumeration.
That is, this change fixes thr fact that this change:

7bda071 [dev][usb-xhci] xhci_reset_endpoint() can now recover from error states

broke this change:

245474e [udev][usb-xhci] Recover from stalls during device enumeration

Change-Id: I04a5ebd2ad67196855b7c3b043428906a386cac2


# 7bda071c 23-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-xhci] xhci_reset_endpoint() can now recover from error states

Previously usb_reset_endpoint() only reset endpoints in halted state,
but can now recover from errored endpoints as well.

xhci_reset_endpoint() no longer holds the endpoint's lock, since that
can result in deadlocks with xhci_handle_transfer_event()

Part of fix for NET-97.

Change-Id: I973928804e47424109a98fd198e2fff965d19627


# 11a4cc32 22-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Fail transactions with MX_ERR_IO_NOT_PRESENT after device is removed

Change-Id: I2fed3bc59a6b708a7fc9521b6cf9daad1dd1529d


# 245474ee 22-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Recover from stalls during device enumeration

The asix-88179 based Plugable USB ethernet/hub combo has an intermittent problem
where the initial get device descriptor command will fail, resulting in the
USB 2.0 side of the hub not to enumerate.
Catching this and clearing the stall allows us to recover.

Also added accessor for reading endpoint state from the endpoint context.

Change-Id: I33a1f78513c55fd2d16d44d8dfaac979ccfc2b23


# da8a9850 21-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Fix iotxn leak that could occur when handling errors

The XHCI controller can return errors for any TRB in the transfer ring.
When that occurs, we may have to search further down the ring to find the
"event data" TRB which contains a pointer to the iotxn for the failed transfer.
We used to only search 5 TRBs, which is now insufficient given that
scatter/gather support can split a transaction across many TRBs.
So now we search the full length of the transfer ring for the "event data" TRB
to ensure that we can complete the iotxn for the failed transfer.

Change-Id: I286d6903b6858e57c84c296763e371e6c6e8a440


# 83087d19 21-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb] Clean up error code usage

Previously most USB errors were being reported as MX_ERR_PEER_CLOSED.
We now return MX_ERR_IO_NOT_PRESENT to indicate that the USB device is no longer attached.
Other possibly recoverable errors are now reported as MX_ERR_IO.
Attempting to use a disabled endpoint now returns MX_ERR_BAD_STATE.
We continue to use MX_ERR_IO_REFUSED to report stalled endpoints.

Change-Id: I254a1e5ee7c6ae34c70d36a9a2d40deaa2f3d781


# d68f506b 14-Jun-2017 Mike Voydanoff <voydanoff@google.com>

[udev][usb-xhci] Scatter/gather support for isochronous transactions

Change-Id: I43a167e44a92e528ce55b26423eb2534837d1261


# b2d14526 09-Jun-2017 Tim Kilbourn <tkilbourn@google.com>

[dev][usb] Use new magenta error names

Change-Id: Ie4901fe957ee96cf7c7d425a948c1b66a0d3a0f3


# 9f5cd55f 07-Jun-2017 Brian Swetland <swetland@google.com>

[udev][usb-xhci] rename

Change-Id: I9301fac7ba04cb881cbc84cc4d34f9a3061ed848