Issue with reset timing on UHCI root hub
A printf placed between PR (Port Reset) deassert and PE (Port Enable) assert was causing a lot of trouble. Without that, get device descriptor operation used to fail. Reasonably we thought it to be a timing issue. mdelay(100), mdelay(1000), and even mdelay(10000) did not work.
In gPXE we restore interrupts momentarily for the time we print something to the console. So, we guessed that the BIOS is doing something in the interrupt handler the moment interrupts were restored. So, I began to look at the UHCI codein the linux kernel in search of interrupt handlers. But it was of no use at all. I wasted around 10 days with this really nasty buglet.
Finally, I decided to ask the guys at linux-usb@vger.kernel.org for ideas. I knew one Alan Stern there. Fortunately, he replied saying that the time delay was too much as the device would go to suspend then. He advised to keep it < 1ms. I put a udelay(10) there, and things worked perfectly! Thanks Alan. Please read the thread for yourself here.