summary refs log tree commit diff
path: root/devices/src/usb/xhci
Commit message (Collapse)AuthorAge
* devices: usb: add unit test for ring buffer cycleDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | Validate that the toggle_cycle code works as expected. I initially misunderstood the behavior of toggle_cycle in the Link TRB, but it appears to work correctly as written after writing a unit test to verify my understanding. Add the unit test anyway to be sure the behavior doesn't regress in the future. BUG=None TEST=cargo test -p devices Change-Id: I9dbc34b26225945fa6d31c34261f53d5b64ba259 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2199956 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: usb: ignore busy flag in interrupterDaniel Verkamp2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | This works around an issue where the xhci controller hangs from the guest's point of view, with the guest kernel eventually timing out and disabling the controller. The xHCI spec says that the EHB (Event Handler Busy) bit should be cleared before signalling another interrupt. This bit is set by the controller before triggering an interrupt, and it is meant to be cleared by the guest (via write-1-to-clear) when it is done handling the interrupt. However, it seems that there is a race going on between the clearing and setting of this bit. Removing the check seems to avoid the issue, since we never get into the state where we think EHB is set but the guest thinks it is clear (where no further interrupts would be triggered). This will potentially trigger more interrupts than strictly necessary, but the Linux kernel xhci driver handles interrupts with no events available gracefully. BUG=chromium:1082930 TEST=`while adb shell echo hi; do : ; done` for 8+ hours without hangs Change-Id: I3c08f0c5675be10d8e46f73714d684f7ba3a3903 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202745 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: usb: remove interrupter pending variableDaniel Verkamp2020-05-16
| | | | | | | | | | | | | | | | The pending variable was just duplicating state that can easily be determined based on whether the ring is empty. Remove the variable and replace it with an equivalent check in interrupt_if_needed() to avoid the possibility of accidentally getting these out of sync. BUG=chromium:1082930 TEST=cargo test -p devices Change-Id: Icb90e3d09c43de244f5fecffb0e55d4635be6d2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202744 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: pci: refactor PCI devices to use PciAddress.Tomasz Jeznach2020-05-01
| | | | | | | | | | | | | | Simple refactor of PCI device addressing to use PciAddress type providing bus:device.function number. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I7755ad6b31aa8c882475cd8212630e1cc86ef49e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172766 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* Remove redundant single-component importsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | Fix clippy 1.43.0 clippy::single-component-path-imports warnings. BUG=None TEST=bin/clippy Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: xhci: support TRB Immediate Data bitDaniel Verkamp2020-02-03
| | | | | | | | | | | | | | | | | | | Transfer TRBs have a flag that indicates that data is transferred within the TRB itself instead of as a separate buffer. Add support for this type of transfer in the ScatterGatherBuffer implementation. This fixes USB support when using Linux 5.1+ as the guest kernel, since it now uses immediate data transfers. BUG=chromium:1046564 TEST=`adb root` to connected phone on Linux 5.4 guest kernel Change-Id: I6c37db422ac8e65d10e1a91807b15e903ad614de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2026262 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: xhci: use get_bar_addr() to find BAR 0Daniel Verkamp2020-01-23
| | | | | | | | | | | | | | Don't store the BAR value, as it can potentially be updated by the guest. (This is not supported by our PCI device model just yet, but this is still the correct thing to do and matches other crosvm PCI devices.) BUG=None TEST=Add USB device on nami Change-Id: Ie42d08429e7ff124178c818877b4cee83003d66f Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1924782 Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: fix warning about extra parensDylan Reid2019-12-23
| | | | | | | | | | | rust 1.40 has a new warning when there are extra parens, soRemove them. Change-Id: Ibb565cac41ba8d72879f4cb8b949f2be30e55167 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1978140 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* resource: Rename device memory to mmioXiong Zhang2019-11-10
| | | | | | | | | | | | | | Since unified allocator is used to allocate mmio, this patch remove the device memory name, and rename device to mmio. BUG=chromium:992270 TEST=this patch doesn't change function, run build_test Change-Id: I234b0db4b3c5de8cfee372ace5212a980564d0c7 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895234 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Resource: Unify mmio allocatorXiong Zhang2019-11-10
| | | | | | | | | | | | | | | | | | | | | | | | | | Current mmio and device two allocators exist, the purpose to define two allocator is: Accessing to gpa from mmio allocator cause vm exit, while gpa from device allocator doesn't cause vm exit. Whether vm exits exist or not, dependency on whether vm->add_device_memory() is called with gpa from allocator or not.Even if gpa is from mmio alloator, and vm->add_device_memory() is called with this gpa, accessing this gpa won't cause vm exit. So mmio allocator and device allocator couldn't guarantee the original purpose. This patch unify mmio allocator and device allocator into one mmio allocator. BUG=chromium:992270 TEST=this patch doesn't change function, so just run build_test Change-Id: If87d5c2838eb122ef627fa45c394b1b3ccfafeb0 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895233 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Remove unneeded return statementsDaniel Verkamp2019-11-08
| | | | | | | | | | | BUG=None TEST=bin/clippy Change-Id: I2cf3b961baefd21fedaa6b545c1c7ecfb25a9efc Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1896088 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Remove duplicated semicolonsDaniel Verkamp2019-11-08
| | | | | | | | | | | | | This will be checked by Rust 1.39.0's rustfmt. BUG=None TEST=bin/fmt --check Change-Id: I8f037207af39f7de1c346365259a10dbe044450b Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1904162 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Reformat with rustfmt from Rust 1.38.0Daniel Verkamp2019-10-17
| | | | | | | | | | | | | | | | This just removes a few extraneous blank lines that the new rustfmt doesn't like. BUG=None TEST=bin/fmt --check Change-Id: I4482f873bdfe19f2f73f86cfdd99d6cce873593c Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1863000 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* usb: replace libusb with Rust usb_util libraryDaniel Verkamp2019-10-17
| | | | | | | | | | | | | | | | | | | | | Drop the dependency on libusb and reimplement the host USB backend using usb_sys to wrap the Linux usbdevfs ioctls. This allows sandboxing to work without any dependency on libusb patches, and it gives us the flexibility to modify and update the USB backend without depending on an external third-party library. BUG=chromium:987833 TEST=`adb logcat` on nami with Nexus 5 attached TEST=deploy app to phone with Android Studio TEST=Run EdgeTPU USB accelerator demo (including DFU mode transition) Cq-Depend: chromium:1773695 Change-Id: I4321c2b6142caac15f48f197795a37d59d268831 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1783601 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: join worker threads in drop()Daniel Verkamp2019-09-17
| | | | | | | | | | | | | | Make sure all devices join any threads they spawn before returning from the drop() handler after signaling the exit event. BUG=chromium:992494 TEST=crosvm exits without errors Change-Id: I6bc91c32a08f568b041765044caa9aff6f7cf4a9 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1802156 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* usb: clean up clippy unit_arg warningDaniel Verkamp2019-08-26
| | | | | | | | | | | | | | | | | | | Fix the last instance of this clippy warning: warning: passing a unit value to a function ... and remove this warning from the "To be resolved" list in bin/clippy. BUG=None TEST=bin/clippy passes without warnings Change-Id: Ic1d558e935366d80eeadb96bf1ff951ce50edd5b Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1766623 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* usb: handle transfer errors after port is detachedTomasz Jeznach2019-08-07
| | | | | | | | | | | | | | | | | | When USB device is detached from kernel driver there might be multiple pending USB transfers enqued, each completing with TransferStatus::NoDevice. Once backend device is detached from system it's ok to ignore subsequent detach request errors in transfer completion handler. BUG=chromium:987500 TEST=ADB USB device attach/detach cycles with active adb service. Change-Id: I4026e68df860c483973f51f9787bf3d48d2716b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1737471 Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* pci: Let device could trap pci config read/writeXiong Zhang2019-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently device impliments PciDevice trait, it will return config register to bus trait at pci cfg r/w, then BusDevice trait on behave of device to do actual pci config r/w. But vfio device need to handle the pci config r/w by itself, as vfio device need to transfer this request to kernel. For pci config read, this patch delete PciDevice->config_registers(), and add PciDevice->read_config_register(), then BusDevice-> config_register_read() call PciDevice->read_config_register(), finally Device could trap the PciConfig Read. For pci config write, it is similiar with pci config read. But the common code is moved into PciConfiguration. BUG=none TEST=none Change-Id: Ie6bd3a8c94f523d6fb1ef3d1e97d087bb0407d9f Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1580457 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: pci: allocate BARs with correct alignmentDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | | | | Each PCI BAR must be aligned to at least its own size to allow the BAR sizing mechanism to work. Change all BAR allocations to use allocate_with_align(), specifying the size as the alignment. In particular, this fixes the alignment of the XHCI BAR, whose size is larger than a page (the default MMIO allocator alignment). BUG=None TEST=Boot vm_kernel in crosvm Change-Id: Icba03771a896b9b4feae608efdb7685fe24f8b98 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660202 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* usb: reset backend device on port resetDaniel Verkamp2019-06-05
| | | | | | | | | | | | | | | | | | | | | | | | This enables the full firmware update/reset/use device in application mode sequence for Edge TPU USB Accelerator. There is a bit of a UI hiccup: once the firmware update and reset is complete, the device re-enumerates with a different VID/PID, and the "Connect to Linux" prompt shows up again. The user must re-affirm that the device should be connected to Linux to proceed with using the Edge TPU. This may be unavoidable - I'm not sure if we can tell the difference between a newly-inserted device and a reset one. Allowing USBDEVFS_DISCONNECT_CLAIM should be safe, since it can only operate on file descriptors passed into the xhci device jail. BUG=chromium:831850 TEST=Run Edge TPU Accelerator demo and verify that it can update FW Change-Id: I3d61c7bd914830ce25448b1ae4d60e1c16f10aed Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1599881 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* crosvm: update xhci abi to use new bit_field featuresJingkui Wang2019-05-25
| | | | | | | | | | | | | | We don't need schema anymore. Will use bool and custom enums. BUG=None TEST=local build and run crosvm Change-Id: I1396916878f2903b17a75f375aee4eec1ced0583 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1564780 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: implement Interrupt on Short Packet bitDaniel Verkamp2019-05-23
| | | | | | | | | | | | | | | | | | | | | Transfer requests have a flag called Interrupt on Short Packet (ISP) that we have been totally ignoring. Now that the control request execution phases have been rearranged in previous changes, we can correctly trigger an event when a transfer fills fewer bytes than requested. This fixes firmware update on the Edge TPU USB Accelerator (Coral): https://coral.withgoogle.com/docs/accelerator/get-started/ BUG=chromium:831850 TEST=Run Edge TPU test model from get-started page Change-Id: I0d21e408a19c2e2eba562362bfe636c75dbb7160 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1593716 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: hold lock throughout resample handlerDaniel Verkamp2019-05-08
| | | | | | | | | | | | | | | | | | Rather than acquiring the lock twice, lock it once and hold it while doing the check and potential follow-up call to interrupt(). This looks like it could be a race to me, but I don't know if it can actually cause problems in practice. In any case, it's better to only acquire the lock once. BUG=chromium:831850 TEST=Test adb in Crostini Change-Id: Id7aa76e543cd5b858faf128f516e8d63e27cf3e7 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1592579 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: set event loop thread nameDaniel Verkamp2019-05-08
| | | | | | | | | | | | | | | Set the name of the thread created to run the Xhci controller event loop so that it can be identified more easily in a debugger. BUG=None TEST=Attach to running crosvm with gdb and verify 'info threads' name Change-Id: Id73a580b35231ec7fa7aec5bd51027d32e483bff Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1594192 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: fix deadlock in try_detach removal pathDaniel Verkamp2019-05-03
| | | | | | | | | | | | | | | | | | | | | | The UsbHub::try_detach function, which is only called from the libusb hotplug callback when devices are removed, calls into port.get_backend_device(), which acquires the backend_device lock, and then calls port.detach(), which also tries to acquire the backend_device lock, while still holding onto the backend_device. This clearly leads to a deadlock. Add an extra block in try_detach to keep the backend_device lock scoped so that it is dropped before calling port.detach(). BUG=chromium:958117 TEST=Hot remove usb device from Crostini; verify it is gone in lsusb Change-Id: Ibbbf68623390e3d25576f544b815c2a5607934fc Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1594158 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: fix serial devices by removing device context verificationJingkui Wang2019-05-01
| | | | | | | | | | | | | | | | | | | | | 1. Removed for device slot reset and evaluate context. The verification was unnecessary and may cause some guest kernel operations to fail. 2. The context was updated after dequeue pointer set 3. Reset device when it's attached. 4. Add seccomp rules to allow the above reset. The verification was copied from another implementation which works for adb, but does not work with serial devices. The verification is also not part of the spec, so we removed it here. BUG=b:131336977 TEST=local build and test Change-Id: Ifd7994ff5512346d1bab27654e60c97a602da8a6 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Signed-off-by: Zach Reizner <zachr@google.com> Reviewed-on: https://chromium-review.googlesource.com/1558934 Tested-by: kokoro <noreply+kokoro@google.com>
* resources+pci: allocator rework (allocation tags)Daniel Prilik2019-04-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | AddressAllocator now maintains a HashMap<Alloc, (u64, u64, u64)>, which uniquely maps a Allocation enum (e.g: PciBar(bus, dev, bar), GpuRenderNode, etc...) to it's address, size, and human-readable tag / description. The interface has also been modified to use Error instead of Option. Aside from improving debugging, tracking allocations will have numerous uses in the future. For example, when allocating guest memory over VmControl sockets, it will be possible to restrict allocations to pre-allocated slices of memory owned by the requesting device. To plumb through PCI information to PCI devices, this CL necessitated the addition of a PciDevice method called `assign_bus_dev`, which notifies PCI devices of their uniquely assigned Bus and Device numbers. BUG=chromium:936567 TEST=cargo test -p resources && cargo build --features="gpu gpu-forward" Change-Id: I8b4b0e32c6f3168138739249ede53d03143ee5c3 Reviewed-on: https://chromium-review.googlesource.com/1536207 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* edition: Eliminate ref keywordDavid Tolnay2019-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html which also covers the new mental model that the Rust Book will use for teaching binding modes and has been found to be more friendly for both beginners and experienced users. Before: match *opt { Some(ref v) => ..., None => ..., } After: match opt { Some(v) => ..., None => ..., } TEST=cargo check --all-features TEST=local kokoro Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7 Reviewed-on: https://chromium-review.googlesource.com/1566669 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Eliminate blocks superseded by NLLDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve unused_unitDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I96fe9711d99a999cda706a8b78f79ff5ef8f60de Reviewed-on: https://chromium-review.googlesource.com/1566892 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve unneeded_field_patternDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Ia0e0163441fafd4ce44fef7ebaa18d1cc947e20e Reviewed-on: https://chromium-review.googlesource.com/1566891 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve single_matchDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Iea0d3539b3ab587a2d97f676e1d9c7a239504308 Reviewed-on: https://chromium-review.googlesource.com/1566748 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve clone_on_copyDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Ia9f58fd7ba0b7af6eee455f52b3b9004547aa25e Reviewed-on: https://chromium-review.googlesource.com/1566659 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve block_in_if_condition_stmtDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I36153632fbe21e8e23a36f0522b7afa1a72b5192 Reviewed-on: https://chromium-review.googlesource.com/1566658 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve while_let_loopDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Iae447ec2c1b095286ab02cd153bd2daafe95fae1 Reviewed-on: https://chromium-review.googlesource.com/1566894 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Fill in macro importsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | Macros were previously imported through `#[macro_use] extern crate`, which is basically a glob import of all macros from the crate. As of 2018 edition of Rust, `extern crate` is no longer required and macros are imported individually like any other item from a dependency. This CL fills in all the appropriate macro imports that will allow us to remove our use of `extern crate` in a subsequent CL. TEST=cargo check --all-features --tests TEST=kokoro Change-Id: If2ec08b06b743abf5f62677c6a9927c3d5d90a54 Reviewed-on: https://chromium-review.googlesource.com/1565546 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* usb: Simplify imports from usb_utilDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | The devices crate imports things from usb_util which is a separate crate. Importing from a crate normally looks like: use name_of_crate::path::to::ThingToImport; In the case it would be e.g.: use usb_util::hotplug::UsbHotplugHandler; Importing these things through crate::usb::usb_util is unnecessary. TEST=cargo check Change-Id: I70554639a71b2423c1e13a30361d5f9d92e9d9a9 Reviewed-on: https://chromium-review.googlesource.com/1565725 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* edition: Use 2018-style paths in devices crateDavid Tolnay2019-04-09
| | | | | | | | | | | | | | | | These are import paths in new code added since CL:1513054 that need to be made compatible with 2018 edition's treatment of paths. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: Icb3ecf2fb2015332e0c03cdc22bff2ecab2c40df Reviewed-on: https://chromium-review.googlesource.com/1559264 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Use dyn syntax for trait objectsDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | | | | Found by running: `cargo rustc -- -D bare_trait_objects` Bare trait objects like `&Trait` and `Box<Trait>` are soft-deprecated in 2018 edition and will start warning at some point. As part of this, I replaced `Box<Trait + 'static>` with `Box<dyn Trait>` because the 'static bound is implied for boxed trait objects. TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I41c4f13530bece8a34a8ed1c1afd7035b8f86f19 Reviewed-on: https://chromium-review.googlesource.com/1513059 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* fix endpoint id in set tr dequeue pointerJingkui Wang2019-03-30
| | | | | | | | | | | | | | We were lucky that adb does not trigger this code path, but Arduino do. BUG=None TEST=local build, deploy and run Change-Id: I0cf02c5de0a73af4e5cb6f5b668cef6606ed166b Reviewed-on: https://chromium-review.googlesource.com/1542032 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: remove unused/abused fd argument from EventHandler::on_eventZach Reizner2019-03-18
| | | | | | | | | | | | | | | | | | None of instances of EventHandler::on_event actually used the fd. The PollfdChangeHandler::remove_poll_fd callback fabricated a potentially valid fd (0), which went undetected because nobody used it. Additionally, using RawFds almost always requires unsafe and should be avoided. CQ-DEPEND=CL:1522214 BUG=chromium:831850 TEST=cargo test Change-Id: I095edbcad317e4832b1fb29fd08d602fbde4fd5d Reviewed-on: https://chromium-review.googlesource.com/1525135 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* implement xhci and add it to pci busJingkui Wang2019-03-17
| | | | | | | | | | | | | | Implement xhci controller, setup seccomp filters and add xhci to pci bus. CQ-DEPEND=CL:1512761 BUG=chromium:831850 TEST=local build Change-Id: I5c05452ece66e99d3a670e259e095fca616e835d Reviewed-on: https://chromium-review.googlesource.com/1512762 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* usb: add host backendJingkui Wang2019-03-16
| | | | | | | | | | | | | | | | | | Host backend implement backend device. It will attach a read device to xhci controller. Also squashed from ce6b35, author: zachr@. CQ-DEPEND=CL:1510820 BUG=chromium:831850 TEST=local build Change-Id: Idcf2d7d6aca92de9859b7c38d1bf1d98032eae91 Reviewed-on: https://chromium-review.googlesource.com/1512761 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: Add device slot, command ring and transfer ringJingkui Wang2019-03-16
| | | | | | | | | | | | | | | | Device can be assigned to slot. Command ring handles usb commands, transfer ring handles usb transfers. CQ-DEPEND=CL:1510819 BUG=chromium:831850 TEST=cargo test Change-Id: Ib0836ee518d1c7a3e902630c7ea04e29b9496c80 Reviewed-on: https://chromium-review.googlesource.com/1510820 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: add usb hub, transfer and usb backend interfaceJingkui Wang2019-03-16
| | | | | | | | | | | | | | | Those are bridges between xhci and backend. CQ-DEPEND=CL:1510818 BUG=chromium:831850 TEST=cargo test Change-Id: I04feab449d48b0c908aeebfda08d1869239cbe6f Reviewed-on: https://chromium-review.googlesource.com/1510819 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: add ring buffer and ring buffer controllerJingkui Wang2019-03-16
| | | | | | | | | | | | | | for ring buffer, guest kernel is producer and crosvm is consumer CQ-DEPEND=1510817 BUG=chromium:831850 TEST=cargo test Change-Id: Ib62d2b42de1a77ff71ca0e2a0066feacc56dddc1 Reviewed-on: https://chromium-review.googlesource.com/1510818 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: Verify usb_debug args even when not loggingDavid Tolnay2019-03-16
| | | | | | | | | | | | | | | | | | Implementing this macro by ignoring the args and expanding to nothing makes it possible to pass invalid args like `usb_debug!("{}")`. Use `if false` instead to ensure that the args are valid formatter args. As part of this, fix a call to a non-existent function inside one of the usb_debug invocations. TEST=cargo check devices Change-Id: Id82dad7b021060dce7b4d3b828bbd21aaa6ef410 Reviewed-on: https://chromium-review.googlesource.com/1518730 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* add scatter gather bufferJingkui Wang2019-03-13
| | | | | | | | | | | | | | | | scatter gather buffer is a buffer with segments. CQ-DEPEND=CL:1510816 BUG=chromium:831850 TEST=cargo test Change-Id: Iea54d5b3d6f9194113f6237eb14aafab71ca2ff9 Reviewed-on: https://chromium-review.googlesource.com/1510817 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: add interrupter and resample handler for xhciJingkui Wang2019-03-13
| | | | | | | | | | | | | | | | Interrupter owns event ring and send interrupt. Resample handler will reassert interrupt when resample happens. CQ-DEPEND=CL:1510815 BUG=chromium:831850 TEST=local build Change-Id: If2c4349e50d0ab275f29dfa48b0860c86f0c8ea3 Reviewed-on: https://chromium-review.googlesource.com/1510816 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* devices: compile usb module and update current codeJingkui Wang2019-03-13
| | | | | | | | | | | | | | | | | | | This patch did the following: start compile usb module fix register macro update error handling reformat code update xhci reg setup to support usb3 and usb2 BUG=chromium:831850 TEST=local build CQ-DEPEND=CL:1510813 Change-Id: I851cf02d01ae6e988b2628552cf57c1f43aa86c8 Reviewed-on: https://chromium-review.googlesource.com/1510814 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>