+static struct xhci_device *xhci_find_alloc_device(struct usb_xhci_s *xhci,
struct usbdevice_s *usbdev)
+{
- ASSERT32FLAT();
- struct xhci_device *dev;
- for (dev = xhci->list; dev != NULL; dev = dev->next) {
if (dev->usbdev == usbdev) {
return dev;
}
- }
I have not done a full review, but I did notice the above. The freelist has a longer lifetime than a usbdev, so I don't think it is safe to compare to it. (Nothing stops a usbdev from being free'd and a new one being alloc'd at the same address.)
Unlinking the usbdev on disconnect() should take care of this. Incremental fix attached.
Can the needed info from usbdev be copied into the pipe so that a long held reference isn't needed?
This is needed when allocating a new pipe. Basically because xhci has not only per-pipe data structures (like ehci/uhci/ohci), but also a per-device data structure called "device context". When allocating a new pipe I'll have to find the device context so I can hook up the endpoint context for the new pipe properly.
cheers, Gerd