From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] ahci: fix device detect emulation.
Date: Thu, 23 Jun 2011 15:59:37 +0200 [thread overview]
Message-ID: <1308837577-15232-1-git-send-email-kraxel@redhat.com> (raw)
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
next reply other threads:[~2011-06-23 13:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-23 13:59 Gerd Hoffmann [this message]
2011-06-24 7:24 ` [Qemu-devel] [PATCH] ahci: fix device detect emulation Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308837577-15232-1-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).