From patchwork Tue Sep 4 20:08:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 181668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 63A872C0085 for ; Wed, 5 Sep 2012 06:08:22 +1000 (EST) Received: from localhost ([::1]:44324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8zQ4-0007Oy-En for incoming@patchwork.ozlabs.org; Tue, 04 Sep 2012 16:08:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8zPx-0007OW-6T for qemu-devel@nongnu.org; Tue, 04 Sep 2012 16:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8zPv-00053b-Rg for qemu-devel@nongnu.org; Tue, 04 Sep 2012 16:08:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8zPv-00053W-JL for qemu-devel@nongnu.org; Tue, 04 Sep 2012 16:08:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q84K892G018134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Sep 2012 16:08:09 -0400 Received: from redhat.com (dhcp-185-114.bos.redhat.com [10.16.185.114]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q84K88cJ015036; Tue, 4 Sep 2012 16:08:08 -0400 Date: Tue, 4 Sep 2012 16:08:08 -0400 From: Jason Baron Message-Id: <201209042008.q84K88cJ015036@int-mx11.intmail.prod.int.phx2.redhat.com> To: kwolf@redhat.com, agraf@suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, mst@redhat.com, jan.kiszka@siemens.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, yamahata@valinux.co.jp, alex.williamson@redhat.com, pbonzini@redhat.com, afaerber@suse.de, armbru@redhat.com Subject: [Qemu-devel] [PATCH v2] ahci: properly reset PxCMD on HBA reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org While testing q35, I found that windows 7 (specifically, windows 7 ultimate with sp1 x64), wouldn't install because it can't find the cdrom or disk drive. The failure message is: 'A required cd/dvd device driver is missing. If you have a driver floppy disk, CD, DVD, or USB flash drive, please insert it now.' This can also be reproduced on piix by adding an ahci controller, and observing that windows 7 does not see any devices behind it. The problem is that when windows issues a HBA reset, qemu does not reset the individual ports' PxCMD register. Windows 7 then reads back the PxCMD register and presumably assumes that the ahci controller has already been initialized. Windows then never sets up the PxIE register to enable interrupts, and thus it never gets irqs back when it sends ata device inquiry commands. This change brings qemu into ahci 1.3 specification compliance. Section 10.4.3 HBA Reset: " When GHC.HR is set to '1', GHC.AE, GHC.IE, the IS register, and all port register fields (except PxFB/PxFBU/PxCLB/PxCLBU) that are not HwInit in the HBA's register memory space are reset. " I've also re-tested Fedora 16 and 17 to verify that they continue to work with this change. Signed-off-by: Jason Baron Acked-by: Alexander Graf --- changes in v2: -continue to set PORT_CMD_SPIN_UP, PORT_CMD_POWER_ON on reset (Kevin Wolf) -drop cmd init in ahci_init() (Alexander Graf) hw/ide/ahci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 3d41771..97a0fa9 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1175,7 +1175,6 @@ void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports) ad->port_no = i; ad->port.dma = &ad->dma; ad->port.dma->ops = &ahci_dma_ops; - ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON; } } @@ -1199,6 +1198,7 @@ void ahci_reset(AHCIState *s) pr->irq_stat = 0; pr->irq_mask = 0; pr->scr_ctl = 0; + pr->cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON; ahci_reset_port(s, i); } }