mirror of https://gitee.com/openkylin/qemu.git
ide: make all commands go through cmd_done
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> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
08ee9e3368
commit
c7e73adb48
|
@ -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. */
|
/* We're ready to process the command in FIS byte 2. */
|
||||||
ide_exec_cmd(&s->dev[port].port, cmd_fis[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:
|
out:
|
||||||
|
@ -1036,11 +1031,6 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
s->end_transfer_func(s);
|
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,
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ahci_async_cmd_done(IDEDMA *dma)
|
static void ahci_cmd_done(IDEDMA *dma)
|
||||||
{
|
{
|
||||||
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, 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 */
|
/* update d2h status */
|
||||||
ahci_write_fis_d2h(ad, NULL);
|
ahci_write_fis_d2h(ad, NULL);
|
||||||
|
@ -1132,7 +1122,7 @@ static const IDEDMAOps ahci_dma_ops = {
|
||||||
.prepare_buf = ahci_dma_prepare_buf,
|
.prepare_buf = ahci_dma_prepare_buf,
|
||||||
.rw_buf = ahci_dma_rw_buf,
|
.rw_buf = ahci_dma_rw_buf,
|
||||||
.set_unit = ahci_dma_set_unit,
|
.set_unit = ahci_dma_set_unit,
|
||||||
.async_cmd_done = ahci_async_cmd_done,
|
.cmd_done = ahci_cmd_done,
|
||||||
.restart_cb = ahci_dma_restart_cb,
|
.restart_cb = ahci_dma_restart_cb,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,9 +174,9 @@ void ide_atapi_cmd_reply_end(IDEState *s)
|
||||||
#endif
|
#endif
|
||||||
if (s->packet_transfer_size <= 0) {
|
if (s->packet_transfer_size <= 0) {
|
||||||
/* end of transfer */
|
/* end of transfer */
|
||||||
ide_transfer_stop(s);
|
|
||||||
s->status = READY_STAT | SEEK_STAT;
|
s->status = READY_STAT | SEEK_STAT;
|
||||||
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
|
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
|
||||||
|
ide_transfer_stop(s);
|
||||||
ide_set_irq(s->bus);
|
ide_set_irq(s->bus);
|
||||||
#ifdef DEBUG_IDE_ATAPI
|
#ifdef DEBUG_IDE_ATAPI
|
||||||
printf("status=0x%x\n", s->status);
|
printf("status=0x%x\n", s->status);
|
||||||
|
|
|
@ -440,12 +440,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)
|
void ide_transfer_stop(IDEState *s)
|
||||||
{
|
{
|
||||||
s->end_transfer_func = ide_transfer_stop;
|
s->end_transfer_func = ide_transfer_stop;
|
||||||
s->data_ptr = s->io_buffer;
|
s->data_ptr = s->io_buffer;
|
||||||
s->data_end = s->io_buffer;
|
s->data_end = s->io_buffer;
|
||||||
s->status &= ~DRQ_STAT;
|
s->status &= ~DRQ_STAT;
|
||||||
|
ide_cmd_done(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ide_get_sector(IDEState *s)
|
int64_t ide_get_sector(IDEState *s)
|
||||||
|
@ -588,20 +596,13 @@ static void dma_buf_commit(IDEState *s)
|
||||||
qemu_sglist_destroy(&s->sg);
|
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)
|
void ide_set_inactive(IDEState *s, bool more)
|
||||||
{
|
{
|
||||||
s->bus->dma->aiocb = NULL;
|
s->bus->dma->aiocb = NULL;
|
||||||
if (s->bus->dma->ops->set_inactive) {
|
if (s->bus->dma->ops->set_inactive) {
|
||||||
s->bus->dma->ops->set_inactive(s->bus->dma, more);
|
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)
|
void ide_dma_error(IDEState *s)
|
||||||
|
@ -849,7 +850,7 @@ static void ide_flush_cb(void *opaque, int ret)
|
||||||
|
|
||||||
bdrv_acct_done(s->bs, &s->acct);
|
bdrv_acct_done(s->bs, &s->acct);
|
||||||
s->status = READY_STAT | SEEK_STAT;
|
s->status = READY_STAT | SEEK_STAT;
|
||||||
ide_async_cmd_done(s);
|
ide_cmd_done(s);
|
||||||
ide_set_irq(s->bus);
|
ide_set_irq(s->bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1773,6 +1774,7 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
|
||||||
s->status |= SEEK_STAT;
|
s->status |= SEEK_STAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ide_cmd_done(s);
|
||||||
ide_set_irq(s->bus);
|
ide_set_irq(s->bus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ struct IDEDMAOps {
|
||||||
DMAIntFunc *rw_buf;
|
DMAIntFunc *rw_buf;
|
||||||
DMAIntFunc *set_unit;
|
DMAIntFunc *set_unit;
|
||||||
DMAStopFunc *set_inactive;
|
DMAStopFunc *set_inactive;
|
||||||
DMAVoidFunc *async_cmd_done;
|
DMAVoidFunc *cmd_done;
|
||||||
DMARestartFunc *restart_cb;
|
DMARestartFunc *restart_cb;
|
||||||
DMAVoidFunc *reset;
|
DMAVoidFunc *reset;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue