From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, John Snow <jsnow@redhat.com>,
stefanha@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 16/28] ide: make all commands go through cmd_done
Date: Mon, 7 Jul 2014 14:17:57 -0400 [thread overview]
Message-ID: <1404757089-4836-17-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1404757089-4836-1-git-send-email-jsnow@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
AHCI has code to fill in the D2H FIS trigger the IRQ all over the place.
Centralize this in a single cmd_done callback by generalizing the existing
async_cmd_done callback.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
---
hw/ide/ahci.c | 16 +++-------------
hw/ide/atapi.c | 2 +-
hw/ide/core.c | 20 +++++++++++---------
hw/ide/internal.h | 2 +-
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index e1f27bd..b40ec06 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -969,11 +969,6 @@ static int handle_cmd(AHCIState *s, int port, int slot)
/* We're ready to process the command in FIS byte 2. */
ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);
-
- if ((s->dev[port].port.ifs[0].status & (READY_STAT|DRQ_STAT|BUSY_STAT)) ==
- READY_STAT) {
- ahci_write_fis_d2h(&s->dev[port], cmd_fis);
- }
}
out:
@@ -1036,11 +1031,6 @@ out:
}
s->end_transfer_func(s);
-
- if (!(s->status & DRQ_STAT)) {
- /* done with DMA */
- ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS);
- }
}
static void ahci_start_dma(IDEDMA *dma, IDEState *s,
@@ -1102,11 +1092,11 @@ static int ahci_dma_set_unit(IDEDMA *dma, int unit)
return 0;
}
-static void ahci_async_cmd_done(IDEDMA *dma)
+static void ahci_cmd_done(IDEDMA *dma)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
- DPRINTF(ad->port_no, "async cmd done\n");
+ DPRINTF(ad->port_no, "cmd done\n");
/* update d2h status */
ahci_write_fis_d2h(ad, NULL);
@@ -1132,7 +1122,7 @@ static const IDEDMAOps ahci_dma_ops = {
.prepare_buf = ahci_dma_prepare_buf,
.rw_buf = ahci_dma_rw_buf,
.set_unit = ahci_dma_set_unit,
- .async_cmd_done = ahci_async_cmd_done,
+ .cmd_done = ahci_cmd_done,
.restart_cb = ahci_dma_restart_cb,
};
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 3b419b3..3d92b52 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -174,9 +174,9 @@ void ide_atapi_cmd_reply_end(IDEState *s)
#endif
if (s->packet_transfer_size <= 0) {
/* end of transfer */
- ide_transfer_stop(s);
s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
+ ide_transfer_stop(s);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
diff --git a/hw/ide/core.c b/hw/ide/core.c
index d900ba0..41ca92e 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -442,12 +442,20 @@ void ide_transfer_start(IDEState *s, uint8_t *buf, int size,
}
}
+static void ide_cmd_done(IDEState *s)
+{
+ if (s->bus->dma->ops->cmd_done) {
+ s->bus->dma->ops->cmd_done(s->bus->dma);
+ }
+}
+
void ide_transfer_stop(IDEState *s)
{
s->end_transfer_func = ide_transfer_stop;
s->data_ptr = s->io_buffer;
s->data_end = s->io_buffer;
s->status &= ~DRQ_STAT;
+ ide_cmd_done(s);
}
int64_t ide_get_sector(IDEState *s)
@@ -573,20 +581,13 @@ static void dma_buf_commit(IDEState *s)
qemu_sglist_destroy(&s->sg);
}
-static void ide_async_cmd_done(IDEState *s)
-{
- if (s->bus->dma->ops->async_cmd_done) {
- s->bus->dma->ops->async_cmd_done(s->bus->dma);
- }
-}
-
void ide_set_inactive(IDEState *s, bool more)
{
s->bus->dma->aiocb = NULL;
if (s->bus->dma->ops->set_inactive) {
s->bus->dma->ops->set_inactive(s->bus->dma, more);
}
- ide_async_cmd_done(s);
+ ide_cmd_done(s);
}
void ide_dma_error(IDEState *s)
@@ -823,7 +824,7 @@ static void ide_flush_cb(void *opaque, int ret)
bdrv_acct_done(s->bs, &s->acct);
s->status = READY_STAT | SEEK_STAT;
- ide_async_cmd_done(s);
+ ide_cmd_done(s);
ide_set_irq(s->bus);
}
@@ -1747,6 +1748,7 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
s->status |= SEEK_STAT;
}
+ ide_cmd_done(s);
ide_set_irq(s->bus);
}
}
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index b919e96..5c19f79 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -433,7 +433,7 @@ struct IDEDMAOps {
DMAIntFunc *rw_buf;
DMAIntFunc *set_unit;
DMAStopFunc *set_inactive;
- DMAVoidFunc *async_cmd_done;
+ DMAVoidFunc *cmd_done;
DMARestartFunc *restart_cb;
DMAVoidFunc *reset;
};
--
1.9.3
next prev parent reply other threads:[~2014-07-07 18:18 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 18:17 [Qemu-devel] [PATCH 00/28] ahci refactoring to support ahci-test suite John Snow
2014-07-07 18:17 ` [Qemu-devel] [PATCH 01/28] blkdebug: report errors on flush too John Snow
2014-07-17 13:28 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 02/28] libqtest: add QTEST_LOG for debugging qtest testcases John Snow
2014-07-17 13:32 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 03/28] ide-test: add test for werror=stop John Snow
2014-07-31 10:58 ` Stefan Hajnoczi
2014-07-31 22:06 ` John Snow
2014-08-01 7:13 ` Markus Armbruster
2014-07-07 18:17 ` [Qemu-devel] [PATCH 04/28] ide: stash aiocb for flushes John Snow
2014-07-31 11:53 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 05/28] ide: simplify reset callbacks John Snow
2014-07-31 11:54 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 06/28] ide: simplify set_inactive callbacks John Snow
2014-07-31 11:54 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 07/28] ide: simplify async_cmd_done callbacks John Snow
2014-07-31 11:54 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 08/28] ide: simplify start_transfer callbacks John Snow
2014-07-31 11:55 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 09/28] ide: wrap start_dma callback John Snow
2014-07-31 11:55 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 10/28] ide: remove wrong setting of BM_STATUS_INT John Snow
2014-07-31 11:56 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 11/28] ide: fold add_status callback into set_inactive John Snow
2014-07-31 11:57 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 12/28] ide: move BM_STATUS bits to pci.[ch] John Snow
2014-07-31 11:57 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 13/28] ide: move retry constants out of BM_STATUS_* namespace John Snow
2014-07-31 12:06 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 14/28] ahci: remove duplicate PORT_IRQ_* constants John Snow
2014-07-31 12:12 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 15/28] ide: stop PIO transfer on errors John Snow
2014-07-31 12:23 ` Stefan Hajnoczi
2014-07-31 23:32 ` John Snow
2014-08-01 7:15 ` Paolo Bonzini
2014-07-07 18:17 ` John Snow [this message]
2014-07-31 12:25 ` [Qemu-devel] [PATCH 16/28] ide: make all commands go through cmd_done Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 17/28] ahci: construct PIO Setup FIS for PIO commands John Snow
2014-07-31 12:32 ` Stefan Hajnoczi
2014-07-07 18:17 ` [Qemu-devel] [PATCH 18/28] q35: Enable the ioapic device to be seen by qtest John Snow
2014-07-31 12:33 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 19/28] qtest: Adding qtest_memset and qmemset John Snow
2014-07-31 12:37 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 20/28] libqos: Correct memory leak John Snow
2014-07-31 12:38 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 21/28] libqtest: Correct small " John Snow
2014-07-31 12:39 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 22/28] libqos: Fixes a " John Snow
2014-07-31 12:40 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 23/28] ahci: Adding basic functionality qtest John Snow
2014-07-31 12:54 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 24/28] ahci: Add test_pci_spec to ahci-test John Snow
2014-07-31 13:19 ` Stefan Hajnoczi
2014-07-31 17:42 ` John Snow
2014-08-01 11:14 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 25/28] ahci: add test_pci_enable " John Snow
2014-07-31 13:36 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 26/28] ahci: Add test_hba_spec " John Snow
2014-07-31 14:01 ` Stefan Hajnoczi
2014-07-31 20:03 ` John Snow
2014-08-01 23:27 ` John Snow
2014-08-04 9:51 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 27/28] ahci: Add test_hba_enable " John Snow
2014-07-31 15:24 ` Stefan Hajnoczi
2014-07-07 18:18 ` [Qemu-devel] [PATCH 28/28] ahci: Add test_identify case " John Snow
2014-07-31 15:28 ` Stefan Hajnoczi
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=1404757089-4836-17-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--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).