On 17/10/16 22:25, BALATON Zoltan wrote:
So it seems to have found the OHCI controller and root hub but failed during trying to use the USB keyboard. That's all I could identify to hint at where it should be debugged. I don't know what the actual problem is.
After a bit of digging I managed to bisect this down to commit 070ea6080606813bdedf667a070917155819abed which had me scratching my head a bit until I enabled USB_DEBUG_ED in usbohci.c:
Good:
|:::::::::::::::::: OHCI TD CHAIN ::::::::::::::::::| +---------------------------------------------------+ |..[SETUP]..........................................| |:|============ OHCI TD at [0x07c9b430] ==========|:| |:| ERRORS = [3] | CONFIG = [0xe2e00000] | |:| |:+-----------------------------------------------+:| |:| C | Condition Code | [14] |:| |:| O | Direction/PID | [0] |:| |:| N | Buffer Rounding | [0] |:| |:| F | Delay Intterrupt | [7] |:| |:| I | Data Toggle | [2] |:| |:| G | Error Count | [0] |:| |:+-----------------------------------------------+:| |:| Current Buffer Pointer [0x07df7730] |:| |:+-----------------------------------------------+:| |:| Next TD [0x07c9b450] |:| |:+-----------------------------------------------+:| |:| Current Buffer End [0x07df7737] |:| |:|-----------------------------------------------|:| |...................................................| +---------------------------------------------------+
Bad:
|:::::::::::::::::: OHCI TD CHAIN ::::::::::::::::::| +---------------------------------------------------+ |..[SETUP]..........................................| |:|============ OHCI TD at [0x07c9b430] ==========|:| |:| ERRORS = [3] | CONFIG = [0xe2e00000] | |:| |:+-----------------------------------------------+:| |:| C | Condition Code | [14] |:| |:| O | Direction/PID | [0] |:| |:| N | Buffer Rounding | [0] |:| |:| F | Delay Intterrupt | [7] |:| |:| I | Data Toggle | [2] |:| |:| G | Error Count | [0] |:| |:+-----------------------------------------------+:| |:| Current Buffer Pointer [0xffff5a50] |:| |:+-----------------------------------------------+:| |:| Next TD [0x07c9b450] |:| |:+-----------------------------------------------+:| |:| Current Buffer End [0xffff5a57] |:| |:|-----------------------------------------------|:| |...................................................| +---------------------------------------------------+
The issue here is that the buffer pointers are pointing to virtual rather than physical addresses.
Digging into this it seems that the problem is that the virt_to_phys() macro in OpenBIOS doesn't actually do anything since virt_offset is always set to zero, i.e. physical address = virtual address. In fact the correct logic for internal physical/virtual address conversions is the va2pa() function found in the OFMEM implementation.
The commit above tried to bring PPC into line with the other architectures by allocating the OpenBIOS stack in the virtual image, but that won't work here due to the incorrect virt_to_phys() macro.
Rather than try and fix that up, I think the best solution for the moment is to continue to use the context but inject the existing stack pointer into the context just before the switch which will ensure that stack allocations also occur in 1:1 mapped address space.
ATB,
Mark.