From 358dd70e161e0faf8159ff178f3ebd7dd07ba7f4 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 22 Feb 2019 17:12:03 -0500 Subject: [PATCH] XHCI: Initialize all fields during endpoint setup. As we reuse memory on a device for endpoints, this is potentially a functional change. --- src/add-ons/kernel/busses/usb/xhci.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index a76e7e2301..fb8a9173be 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -1478,11 +1478,17 @@ XHCI::_InsertEndpointForPipe(Pipe *pipe) device->endpoints[id].device = device; device->endpoints[id].trbs = device->trbs + id * XHCI_MAX_TRANSFERS; - device->endpoints[id].td_head = NULL; - device->endpoints[id].used = 0; device->endpoints[id].trb_addr = device->trb_addr + id * XHCI_MAX_TRANSFERS * sizeof(xhci_trb); + device->endpoints[id].td_head = NULL; + device->endpoints[id].used = 0; + device->endpoints[id].current = 0; + + memset(device->endpoints[id].trbs, 0, + sizeof(xhci_trb) * XHCI_MAX_TRANSFERS); + mutex_init(&device->endpoints[id].lock, "xhci endpoint lock"); + MutexLocker endpointLocker(device->endpoints[id].lock); TRACE("_InsertEndpointForPipe trbs device %p endpoint %p\n", device->trbs, device->endpoints[id].trbs); @@ -2059,7 +2065,6 @@ XHCI::HandleCmdComplete(xhci_trb* trb) fCmdResult[1] = B_LENDIAN_TO_HOST_INT32(trb->dwtrb3); release_sem_etc(fCmdCompSem, 1, B_DO_NOT_RESCHEDULE); } - }