[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 31/35] ahci: add get_cmd_header helper
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 31/35] ahci: add get_cmd_header helper |
Date: |
Sat, 4 Jul 2015 02:07:10 -0400 |
cur_cmd is an internal bookmark that points to the
current AHCI Command Header being processed by the
AHCI state machine. With NCQ needing to occasionally
rely on some of the same AHCI helpers, we cannot use
cur_cmd and will need to grab explicit pointers instead.
In an attempt to begin relying on the cur_cmd pointer
less, add a helper to let us specifically get the pointer
to the command header of particular interest.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
---
hw/ide/ahci.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index b77512b..13b0157 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1116,11 +1116,20 @@ static void process_ncq_command(AHCIState *s, int port,
uint8_t *cmd_fis,
execute_ncq_command(ncq_tfs);
}
+static AHCICmdHdr *get_cmd_header(AHCIState *s, uint8_t port, uint8_t slot)
+{
+ if (port >= s->ports || slot >= AHCI_MAX_CMDS) {
+ return NULL;
+ }
+
+ return s->dev[port].lst ? &((AHCICmdHdr *)s->dev[port].lst)[slot] : NULL;
+}
+
static void handle_reg_h2d_fis(AHCIState *s, int port,
uint8_t slot, uint8_t *cmd_fis)
{
IDEState *ide_state = &s->dev[port].port.ifs[0];
- AHCICmdHdr *cmd = s->dev[port].cur_cmd;
+ AHCICmdHdr *cmd = get_cmd_header(s, port, slot);
uint16_t opts = le16_to_cpu(cmd->opts);
if (cmd_fis[1] & 0x0F) {
@@ -1219,7 +1228,7 @@ static int handle_cmd(AHCIState *s, int port, uint8_t
slot)
DPRINTF(port, "error: lst not given but cmd handled");
return -1;
}
- cmd = &((AHCICmdHdr *)s->dev[port].lst)[slot];
+ cmd = get_cmd_header(s, port, slot);
/* remember current slot handle for later */
s->dev[port].cur_cmd = cmd;
@@ -1572,7 +1581,7 @@ static int ahci_state_post_load(void *opaque, int
version_id)
if (ad->busy_slot < 0 || ad->busy_slot >= AHCI_MAX_CMDS) {
return -1;
}
- ad->cur_cmd = &((AHCICmdHdr *)ad->lst)[ad->busy_slot];
+ ad->cur_cmd = get_cmd_header(s, i, ad->busy_slot);
}
}
--
2.1.0
- [Qemu-devel] [PULL 20/35] qtest/ahci: ncq migration test, (continued)
- [Qemu-devel] [PULL 20/35] qtest/ahci: ncq migration test, John Snow, 2015/07/04
- [Qemu-devel] [PULL 22/35] ahci: stash ncq command, John Snow, 2015/07/04
- [Qemu-devel] [PULL 23/35] ahci: assert is_ncq for process_ncq, John Snow, 2015/07/04
- [Qemu-devel] [PULL 24/35] ahci: refactor process_ncq_command, John Snow, 2015/07/04
- [Qemu-devel] [PULL 25/35] ahci: factor ncq_finish out of ncq_cb, John Snow, 2015/07/04
- [Qemu-devel] [PULL 21/35] ide: add limit to .prepare_buf(), John Snow, 2015/07/04
- [Qemu-devel] [PULL 26/35] ahci: add rwerror=stop support for ncq, John Snow, 2015/07/04
- [Qemu-devel] [PULL 27/35] ahci: correct types in NCQTransferState, John Snow, 2015/07/04
- [Qemu-devel] [PULL 28/35] ahci: correct ncq sector count, John Snow, 2015/07/04
- [Qemu-devel] [PULL 29/35] qtest/ahci: halted NCQ test, John Snow, 2015/07/04
- [Qemu-devel] [PULL 31/35] ahci: add get_cmd_header helper,
John Snow <=
- [Qemu-devel] [PULL 32/35] ahci: ncq migration, John Snow, 2015/07/04
- [Qemu-devel] [PULL 30/35] ahci: add cmd header to ncq transfer state, John Snow, 2015/07/04
- [Qemu-devel] [PULL 34/35] qtest/ahci: halted ncq migration test, John Snow, 2015/07/04
- [Qemu-devel] [PULL 33/35] ahci: Do not map cmd_fis to generate response, John Snow, 2015/07/04
- [Qemu-devel] [PULL 35/35] ahci: fix sdb fis semantics, John Snow, 2015/07/04
- Re: [Qemu-devel] [PULL 00/35] Ide patches, Peter Maydell, 2015/07/05