qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ahci: fix device detect emulation.
@ 2011-06-23 13:59 Gerd Hoffmann
  2011-06-24  7:24 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2011-06-23 13:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf, Gerd Hoffmann

AHCI specs say about the device detection field:

Device Detection (DET): Indicates the interface device detection and Phy
state.

0h - No device detected and Phy communication not established
1h - Device presence detected but Phy communication not established
3h - Device presence detected and Phy communication established
4h - Phy in offline mode as a result of the interface being disabled or
     running in a BIST loopback mode

The "Software Initilaization" section also mentions "If PxSSTS.DET
returns a value of 1h or 3h when read, then system software shall
continue to the next step, ..."

This makes me think that 1h means "tried to detect device but didn't
found one" and 0h means "device detection not finished yet".

Thus qemu should better return 1h instead of 0h when no device is
present on a specific port,

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/ide/ahci.c |    8 +++++---
 hw/ide/ahci.h |    5 +++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 1f008a3..61bfcc7 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -85,11 +85,13 @@ static uint32_t  ahci_port_read(AHCIState *s, int port, int offset)
         val = pr->sig;
         break;
     case PORT_SCR_STAT:
-        if (s->dev[port].port.ifs[0].bs) {
-            val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
+        if (!(pr->cmd & PORT_CMD_SPIN_UP)) {
+            val = SATA_SCR_SSTATUS_DET_DETECT_NOT_DONE;
+        } else if (s->dev[port].port.ifs[0].bs) {
+            val = SATA_SCR_SSTATUS_DET_DETECT_DONE_PHY_UP |
                   SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
         } else {
-            val = SATA_SCR_SSTATUS_DET_NODEV;
+            val = SATA_SCR_SSTATUS_DET_DETECT_DONE_PHY_DOWN;
         }
         break;
     case PORT_SCR_CTL:
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index dc86951..31b24bc 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -165,8 +165,9 @@
 #define STATE_RUN                         0
 #define STATE_RESET                       1
 
-#define SATA_SCR_SSTATUS_DET_NODEV        0x0
-#define SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP 0x3
+#define SATA_SCR_SSTATUS_DET_DETECT_NOT_DONE       0x0
+#define SATA_SCR_SSTATUS_DET_DETECT_DONE_PHY_DOWN  0x1
+#define SATA_SCR_SSTATUS_DET_DETECT_DONE_PHY_UP    0x3
 
 #define SATA_SCR_SSTATUS_SPD_NODEV        0x00
 #define SATA_SCR_SSTATUS_SPD_GEN1         0x10
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-24  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-23 13:59 [Qemu-devel] [PATCH] ahci: fix device detect emulation Gerd Hoffmann
2011-06-24  7:24 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).