[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/28] ahci: construct PIO Setup FIS for PIO command
From: |
John Snow |
Subject: |
[Qemu-devel] [PATCH 17/28] ahci: construct PIO Setup FIS for PIO commands |
Date: |
Mon, 7 Jul 2014 14:17:58 -0400 |
From: Paolo Bonzini <address@hidden>
PIO commands should put a PIO Setup FIS in the receive area when data
transfer ends. Currently QEMU does not do this and only places the
D2H FIS at the end of the operation.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: John Snow <address@hidden>
---
hw/ide/ahci.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index b40ec06..1299920 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -587,6 +587,56 @@ static void ahci_write_fis_sdb(AHCIState *s, int port,
uint32_t finished)
ahci_trigger_irq(s, &s->dev[port], PORT_IRQ_SDB_FIS);
}
+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;
+
+ 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);
+
+ pio_fis = &ad->res_fis[RES_FIS_PSFIS];
+
+ pio_fis[0] = 0x5f;
+ pio_fis[1] = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
+ pio_fis[2] = ad->port.ifs[0].status;
+ pio_fis[3] = ad->port.ifs[0].error;
+
+ pio_fis[4] = cmd_fis[4];
+ pio_fis[5] = cmd_fis[5];
+ pio_fis[6] = cmd_fis[6];
+ pio_fis[7] = cmd_fis[7];
+ pio_fis[8] = cmd_fis[8];
+ pio_fis[9] = cmd_fis[9];
+ pio_fis[10] = cmd_fis[10];
+ pio_fis[11] = cmd_fis[11];
+ pio_fis[12] = cmd_fis[12];
+ pio_fis[13] = cmd_fis[13];
+ pio_fis[14] = 0;
+ pio_fis[15] = ad->port.ifs[0].status;
+ pio_fis[16] = len & 255;
+ pio_fis[17] = len >> 8;
+ pio_fis[18] = 0;
+ pio_fis[19] = 0;
+
+ if (pio_fis[2] & ERR_STAT) {
+ ahci_trigger_irq(ad->hba, ad, PORT_IRQ_TF_ERR);
+ }
+
+ 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)
{
AHCIPortRegs *pr = &ad->port_regs;
@@ -1031,6 +1081,11 @@ out:
}
s->end_transfer_func(s);
+
+ if (!(s->status & DRQ_STAT)) {
+ /* done with PIO send/receive */
+ ahci_write_fis_pio(ad, le32_to_cpu(ad->cur_cmd->status));
+ }
}
static void ahci_start_dma(IDEDMA *dma, IDEState *s,
--
1.9.3
- Re: [Qemu-devel] [PATCH 09/28] ide: wrap start_dma callback, (continued)
- [Qemu-devel] [PATCH 13/28] ide: move retry constants out of BM_STATUS_* namespace, John Snow, 2014/07/07
- [Qemu-devel] [PATCH 16/28] ide: make all commands go through cmd_done, John Snow, 2014/07/07
- [Qemu-devel] [PATCH 10/28] ide: remove wrong setting of BM_STATUS_INT, John Snow, 2014/07/07
- [Qemu-devel] [PATCH 15/28] ide: stop PIO transfer on errors, John Snow, 2014/07/07
- [Qemu-devel] [PATCH 17/28] ahci: construct PIO Setup FIS for PIO commands,
John Snow <=
- [Qemu-devel] [PATCH 18/28] q35: Enable the ioapic device to be seen by qtest., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 21/28] libqtest: Correct small memory leak., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 27/28] ahci: Add test_hba_enable to ahci-test., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 22/28] libqos: Fixes a small memory leak., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 20/28] libqos: Correct memory leak, John Snow, 2014/07/07