Attached is a two part version of the previous patch. Stage1 is enough to get through most OS installs. Stage2 adds unaligned buffer support needed for MS-DOS.
Hmm, patch #1 is still a collection of multiple changes, looks a bit like trying this and that until it somehow worked, without figuring which changes where needed to make the box boot. Also the changelog should describe what was changed and why, not only the effect of the change.
Polling the IRQ status looks like a sensible thing to do. Note that there might be multiple bits set in the IRQ status register, so you can't use irqbits == 0x01 to check the status. qemu fails to boot because of that bug. Also it isn't obvious why you are looking for others than the "Device to Host Register FIS" interrupt. Care to explain?
I've attached a patch which switches ahci over to irq status polling, based on your patch. Works nicely in qemu. Can you give it a spin on real hardware?