[SeaBIOS] [PATCH] [wip] add xhci support

Gerd Hoffmann kraxel at redhat.com
Tue Jun 25 15:34:22 CEST 2013


  Hi,

>> +static void wait_fixed(u32 timeout)
>> +{
>> +    u64 end = calc_future_tsc(timeout);
>> +
>> +    while (!check_tsc(end))
>> +        yield();
>> +}
> 
> How does this differ from msleep()?

I'll check, probably not at all, just havn't noticed (or forgotten) that
there is a msleep() I can use.

>> +#if 1
>> +    /* dirty hack time: try to dig our pipe out of the freelist */
>> +    struct usb_pipe **pfree = &xhci->usb.freelist;
>> +    for (;;) {
>> +        struct usb_pipe *upipe = *pfree;
> 
> Can you explain this further.  What's needed to reuse a previously
> opened pipe on xhci?

xhci interface is very different from ehci / ohci / uhci.  For now I've
found my way to handle things locally in the xhci driver (well, almost,
see attached patch).  Long term we probably want improve the seabios usb
core interfaces though.

xhci has a "device context", containing a "slot context" with device
informations (such as port, speed, ...) and 31 "endpoint contexts" (one
ctl, 15 in, 15 out).  The endpoint contexts contain pointers to the
transfer rings (td queue aequivalent).

If I want release a transfer ring I have to send a command to the xhci
controller first saying I want disable the endpoint.  Likewise when
reusing the ring for another device.  Luckily seabios doesn't actually
release the usb_pipe but sticks it into a freelist only, so this doesn't
disturb the xhci controller and my driver can find them in the freelist.

So, what I think would make sense interface-wise is this:

  (1) replace the free_pipe() + alloc_pipe() cycle when changing the
      maxpacketsize for the control endpoint with an explicit
      reconfigure_ctl_pipe request.
  (2) link pipes to devices not controllers.
  (3) notify host controller when disabling a device, free all pipes
      linked to that device afterwards.

cheers,
  Gerd

-------------- next part --------------
>From 97b1240543e976d1d3e9a32449bdad95ee006853 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel at redhat.com>
Date: Fri, 14 Jun 2013 12:59:44 +0200
Subject: [PATCH] usb: don't free usbdev

xhci needs that.  First because usbdevs ptrs must be unique,
and also because it needs to walk up the chain to the root
port and the usbdevs (of usb hubs) are part of it.
---
 src/usb.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/src/usb.c b/src/usb.c
index ecccd75..a9d3bea 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -378,7 +378,6 @@ usb_hub_port_setup(void *data)
     hub->devcount += count;
 done:
     hub->threads--;
-    free(usbdev);
     return;
 
 resetfail:
-- 
1.7.9.7



More information about the SeaBIOS mailing list