<div dir="ltr"><div><div><div><div><div>Kevin,<br></div>With your patch I'm not seeing that timeout message get displayed.<br></div>I also forgot to mention that the USB thumbdrive will always get identified<br></div>by SeaBIOS and will be listed as a boot device but will hang as soon as it<br>is selected in the F12 boot menu. The activity LED on the thumbdrive only<br>flashes when Seabios is identifying it.<br></div><br></div>Thanks,<br>Dave<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 9, 2014 at 2:46 PM, Kevin O'Connor <span dir="ltr"><<a href="mailto:kevin@koconnor.net" target="_blank">kevin@koconnor.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Sep 09, 2014 at 01:15:04PM -0600, Dave Frodin wrote:<br>
> I'm seeing a problem booting from USB thumbdrives with commit ab9d771ce<br>
>     ehci: Update usb command timeouts to use usb_xfer_time()<br>
><br>
> I'm not quite sure what the problem is other than it not liking the new<br>
> timeouts.<br>
> I couldn't see any problems with the ehci_control() calls to ehci_wait_td().<br>
> But the ehci_send_bulk() only allows the system to boot if I change<br>
>     int ret = ehci_wait_td(pipe, td, end);<br>
> to<br>
>     int ret = ehci_wait_td(pipe, td, timer_calc(5000));<br>
><br>
> One potential problem is that the "end" value is calculated once and reused<br>
> multiple times in the functions. Prior to the commit the timeout value was<br>
> passed<br>
> to the ehci_wait_td() function. Now the final "end" time is passed. So it<br>
> looks like<br>
> once the end timeout is reached in one of the loops that calls<br>
> ehci_wait_td() the<br>
> timer will always be expired for any other calls from that function.<br>
><br>
> One solution might be to get rid of the "end" variable and change the calls<br>
> from<br>
>     ret = ehci_wait_td(pipe, td, end);<br>
> to<br>
>     ret = ehci_wait_td(pipe, td, timer_calc(usb_xfer_time(p, datasize)));<br>
><br>
> Making the above change didn't have any impact on my booting problem until<br>
> I forced the ehci_send_bulk() timeouts to 5000.<br>
<br>
</div></div>Hi Dave,<br>
<br>
Stefan Burger reported a similar problem with that commit.  However,<br>
I'm puzzled what would be causing such a regression - five seconds<br>
should be more then enough time to complete a single usb transaction.<br>
<br>
Do you have serial debugging (or similar) available on the device you<br>
are working with?  If you could provide the output from the debugging<br>
patch below it may help diagnose the issue.<br>
<br>
I also got my Acer c720 back, and will run some tests on it.<br>
<br>
-Kevin<br>
<br>
<br>
--- a/src/hw/usb-ehci.c<br>
+++ b/src/hw/usb-ehci.c<br>
@@ -629,6 +629,7 @@ ehci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize)<br>
             , &pipe->qh, dir, data, datasize);<br>
<br>
     // Allocate 4 tds on stack (with required alignment)<br>
+    u32 starttime = timer_calc(0);<br>
     u32 end = timer_calc(usb_xfer_time(p, datasize));<br>
     u8 tdsbuf[sizeof(struct ehci_qtd) * STACKQTDS + EHCI_QTD_ALIGN - 1];<br>
     struct ehci_qtd *tds = (void*)ALIGN((u32)tdsbuf, EHCI_QTD_ALIGN);<br>
@@ -642,7 +643,7 @@ ehci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize)<br>
         struct ehci_qtd *td = &tds[tdpos++ % STACKQTDS];<br>
<span class="">         int ret = ehci_wait_td(pipe, td, end);<br>
</span>         if (ret)<br>
-            return -1;<br>
+            goto fail;<br>
<br>
         struct ehci_qtd *nexttd_fl = MAKE_FLATPTR(GET_SEG(SS)<br>
                                                  , &tds[tdpos % STACKQTDS]);<br>
@@ -662,10 +663,15 @@ ehci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize)<br>
         struct ehci_qtd *td = &tds[tdpos++ % STACKQTDS];<br>
<span class="">         int ret = ehci_wait_td(pipe, td, end);<br>
</span>         if (ret)<br>
-            return -1;<br>
+            goto fail;<br>
     }<br>
<br>
     return 0;<br>
+fail:<br>
+    dprintf(1, "timeout: start=%x end=%x cur=%x time=%d devaddr=%x datasize=%d\n"<br>
+            , starttime, end, timer_calc(0)<br>
+            , usb_xfer_time(p, datasize), p->devaddr, datasize);<br>
+    return -1;<br>
 }<br>
<br>
 int<br>
</blockquote></div><br></div>