From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com,
John Snow <jsnow@redhat.com>,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 14/16] ahci: Do not map cmd_fis to generate response
Date: Mon, 22 Jun 2015 20:21:13 -0400 [thread overview]
Message-ID: <1435018875-22527-15-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1435018875-22527-1-git-send-email-jsnow@redhat.com>
The Register D2H FIS should copy the current values of
the registers instead of just parroting back the same
values the guest sent back to it.
In this case, the SECTOR COUNT variables are actually
not generally meaningful in terms of standard commands
(See ATA8-AC3 Section 9.2 Normal Outputs), so it actually
probably doesn't matter what we put in here.
Meanwhile, we do need to use the Register update FIS from
the NCQ pathways (in error cases), so getting rid of
references to cur_cmd here is a win for AHCI concurrency.
Signed-off-by: John Snow <jsnow@redhat.com>
---
hw/ide/ahci.c | 50 +++++---------------------------------------------
1 file changed, 5 insertions(+), 45 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index eeb48fb..d344701 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -700,35 +700,13 @@ static void ahci_write_fis_sdb(AHCIState *s, int port, uint32_t finished)
static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len)
{
AHCIPortRegs *pr = &ad->port_regs;
- uint8_t *pio_fis, *cmd_fis;
- uint64_t tbl_addr;
- dma_addr_t cmd_len = 0x80;
+ uint8_t *pio_fis;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
- /* map cmd_fis */
- tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
- cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
- DMA_DIRECTION_TO_DEVICE);
-
- if (cmd_fis == NULL) {
- DPRINTF(ad->port_no, "dma_memory_map failed in ahci_write_fis_pio");
- ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
- return;
- }
-
- if (cmd_len != 0x80) {
- DPRINTF(ad->port_no,
- "dma_memory_map mapped too few bytes in ahci_write_fis_pio");
- dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
- DMA_DIRECTION_TO_DEVICE, cmd_len);
- ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
- return;
- }
-
pio_fis = &ad->res_fis[RES_FIS_PSFIS];
pio_fis[0] = SATA_FIS_TYPE_PIO_SETUP;
@@ -744,8 +722,8 @@ static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len)
pio_fis[9] = s->hob_lcyl;
pio_fis[10] = s->hob_hcyl;
pio_fis[11] = 0;
- pio_fis[12] = cmd_fis[12];
- pio_fis[13] = cmd_fis[13];
+ pio_fis[12] = s->nsector & 0xFF;
+ pio_fis[13] = (s->nsector >> 8) & 0xFF;
pio_fis[14] = 0;
pio_fis[15] = s->status;
pio_fis[16] = len & 255;
@@ -762,9 +740,6 @@ static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len)
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_PIOS_FIS);
-
- dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
- DMA_DIRECTION_TO_DEVICE, cmd_len);
}
static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
@@ -772,22 +747,12 @@ static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
AHCIPortRegs *pr = &ad->port_regs;
uint8_t *d2h_fis;
int i;
- dma_addr_t cmd_len = 0x80;
- int cmd_mapped = 0;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
- if (!cmd_fis) {
- /* map cmd_fis */
- uint64_t tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
- cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
- DMA_DIRECTION_TO_DEVICE);
- cmd_mapped = 1;
- }
-
d2h_fis = &ad->res_fis[RES_FIS_RFIS];
d2h_fis[0] = SATA_FIS_TYPE_REGISTER_D2H;
@@ -803,8 +768,8 @@ static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
d2h_fis[9] = s->hob_lcyl;
d2h_fis[10] = s->hob_hcyl;
d2h_fis[11] = 0;
- d2h_fis[12] = cmd_fis[12];
- d2h_fis[13] = cmd_fis[13];
+ d2h_fis[12] = s->nsector & 0xFF;
+ d2h_fis[13] = (s->nsector >> 8) & 0xFF;
for (i = 14; i < 20; i++) {
d2h_fis[i] = 0;
}
@@ -818,11 +783,6 @@ static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS);
-
- if (cmd_mapped) {
- dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
- DMA_DIRECTION_TO_DEVICE, cmd_len);
- }
}
static int prdt_tbl_entry_size(const AHCI_SG *tbl)
--
2.1.0
next prev parent reply other threads:[~2015-06-23 0:21 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 0:20 [Qemu-devel] [PATCH 00/16] ahci: ncq cleanup, part 2 John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 01/16] ide: add limit to .prepare_buf() John Snow
2015-06-26 14:32 ` Stefan Hajnoczi
2015-06-26 18:16 ` John Snow
2015-06-29 13:34 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-29 18:52 ` John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 02/16] ahci: stash ncq command John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 03/16] ahci: assert is_ncq for process_ncq John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 04/16] ahci: refactor process_ncq_command John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 05/16] ahci: factor ncq_finish out of ncq_cb John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 06/16] ahci: record ncq failures John Snow
2015-06-26 15:35 ` Stefan Hajnoczi
2015-06-26 18:27 ` John Snow
2015-06-29 14:10 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-29 14:24 ` Stefan Hajnoczi
2015-06-29 15:42 ` John Snow
2015-06-29 15:47 ` John Snow
2015-06-30 13:56 ` Stefan Hajnoczi
2015-06-23 0:21 ` [Qemu-devel] [PATCH 07/16] ahci: kick NCQ queue John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 08/16] ahci: correct types in NCQTransferState John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 09/16] ahci: correct ncq sector count John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 10/16] qtest/ahci: halted NCQ test John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 11/16] ahci: add cmd header to ncq transfer state John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 12/16] ahci: ncq migration John Snow
2015-06-26 15:48 ` Stefan Hajnoczi
2015-06-26 16:46 ` John Snow
2015-06-29 14:25 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-23 0:21 ` [Qemu-devel] [PATCH 13/16] ahci: add get_cmd_header helper John Snow
2015-06-26 15:51 ` Stefan Hajnoczi
2015-06-26 18:32 ` John Snow
2015-06-23 0:21 ` John Snow [this message]
2015-06-26 15:59 ` [Qemu-devel] [PATCH 14/16] ahci: Do not map cmd_fis to generate response Stefan Hajnoczi
2015-06-26 17:31 ` John Snow
2015-06-29 14:51 ` Stefan Hajnoczi
2015-06-29 15:07 ` John Snow
2015-06-30 14:50 ` Stefan Hajnoczi
2015-06-23 0:21 ` [Qemu-devel] [PATCH 15/16] qtest/ahci: halted ncq migration test John Snow
2015-06-23 0:21 ` [Qemu-devel] [PATCH 16/16] ahci: fix sdb fis semantics John Snow
2015-06-26 16:11 ` Stefan Hajnoczi
2015-06-26 17:36 ` John Snow
2015-06-29 14:52 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-26 16:11 ` [Qemu-devel] [PATCH 00/16] ahci: ncq cleanup, part 2 Stefan Hajnoczi
2015-06-26 19:27 ` John Snow
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=1435018875-22527-15-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).