Well, I did some more research and figured that it would be a good idea to not only reset the device but reconfigure all ports. This solves the problem of getting the signature from an uninitialized port I mentioned in a previous post. This slows down quite a bit the boot process but it's something I may deal with later.
I updated once again
the repo, its a mess but at least it partially works.
Now the big news: It works! Kinda. Well if after the device is initialized I sleep for like 2 seconds I can use it fine but if I don't I have two behaviors:
1) the bit in PxCI is cleared and the command is not accepted, no error is signaled in PxIS and the command is not executed but marked as if it was; later commands executed after some time will run fine. (this occurs in VMs)
2) the bit in PxCI is never cleared as if the command has been rejected, it is never executed and the bit stays there; it's as if the device hasn't yet received the HBA_PxCMD_ST bit. (this occurs in real hw)
As I said it's easily fixable by adding that delay before running any command but it isn't ideal. I think we are getting closer to making this thing work. Maybe I'm missing the final thing to spin on.
this is the delay thing I mentioned above.