Blame 0166-ahci-properly-reset-PxCMD-on-HBA-reset.patch

5544c1
From 3248d5fbbf9c0fbfd8d42af08aa81fe1e3fe2841 Mon Sep 17 00:00:00 2001
5544c1
From: Jason Baron <jbaron@redhat.com>
5544c1
Date: Tue, 4 Sep 2012 16:08:08 -0400
5544c1
Subject: [PATCH] ahci: properly reset PxCMD on HBA reset
5544c1
5544c1
While testing q35, I found that windows 7 (specifically, windows 7 ultimate
5544c1
with sp1 x64), wouldn't install because it can't find the cdrom or disk drive.
5544c1
The failure message is: 'A required cd/dvd device driver is missing. If you
5544c1
have a driver floppy disk, CD, DVD, or USB flash drive, please insert it now.'
5544c1
This can also be reproduced on piix by adding an ahci controller, and
5544c1
observing that windows 7 does not see any devices behind it.
5544c1
5544c1
The problem is that when windows issues a HBA reset, qemu does not reset the
5544c1
individual ports' PxCMD register. Windows 7 then reads back the PxCMD register
5544c1
and presumably assumes that the ahci controller has already been initialized.
5544c1
Windows then never sets up the PxIE register to enable interrupts, and thus it
5544c1
never gets irqs back when it sends ata device inquiry commands.
5544c1
5544c1
This change brings qemu into ahci 1.3 specification compliance.
5544c1
5544c1
Section 10.4.3 HBA Reset:
5544c1
5544c1
"
5544c1
When GHC.HR is set to '1', GHC.AE, GHC.IE, the IS register, and all port
5544c1
register fields (except PxFB/PxFBU/PxCLB/PxCLBU) that are not HwInit in the
5544c1
HBA's register memory space are reset.
5544c1
"
5544c1
5544c1
I've also re-tested Fedora 16 and 17 to verify that they continue to work with
5544c1
this change.
5544c1
5544c1
Signed-off-by: Jason Baron <jbaron@redhat.com>
5544c1
Acked-by: Alexander Graf <agraf@suse.de>
5544c1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5544c1
(cherry picked from commit 2a4f4f34e6fe55f4c82507c3e7ec9b58c2e24ad4)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 hw/ide/ahci.c | 2 +-
5544c1
 1 file changed, 1 insertion(+), 1 deletion(-)
5544c1
5544c1
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
5544c1
index 5ea3cad..68671bc 100644
5544c1
--- a/hw/ide/ahci.c
5544c1
+++ b/hw/ide/ahci.c
5544c1
@@ -1175,7 +1175,6 @@ void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports)
5544c1
         ad->port_no = i;
5544c1
         ad->port.dma = &ad->dma;
5544c1
         ad->port.dma->ops = &ahci_dma_ops;
5544c1
-        ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -1199,6 +1198,7 @@ void ahci_reset(AHCIState *s)
5544c1
         pr->irq_stat = 0;
5544c1
         pr->irq_mask = 0;
5544c1
         pr->scr_ctl = 0;
5544c1
+        pr->cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;
5544c1
         ahci_reset_port(s, i);
5544c1
     }
5544c1
 }
5544c1
-- 
5544c1
1.7.12.1
5544c1