diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-02-23 11:17:57 -0500 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-03-10 14:02:22 +0100 |
commit | a96cb236290ef8e54b061b30c41835e435905d7a (patch) | |
tree | adc651b6b426c316d311b859b79eeb2ec2c73fb7 /hw | |
parent | fe09c7c9f0e8ed8793e986cf616c8de0a9518fd7 (diff) | |
download | qemu-a96cb236290ef8e54b061b30c41835e435905d7a.zip qemu-a96cb236290ef8e54b061b30c41835e435905d7a.tar.gz qemu-a96cb236290ef8e54b061b30c41835e435905d7a.tar.bz2 |
ide: replace set_unit callback with more IDEBus state
Start moving the initial state of the current request to IDEBus, so that
AHCI can use it. The set_unit callback is not used anymore once this is
done.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1424708286-16483-9-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/ahci.c | 7 | ||||
-rw-r--r-- | hw/ide/core.c | 6 | ||||
-rw-r--r-- | hw/ide/internal.h | 2 | ||||
-rw-r--r-- | hw/ide/macio.c | 1 | ||||
-rw-r--r-- | hw/ide/pci.c | 19 | ||||
-rw-r--r-- | hw/ide/pci.h | 6 |
6 files changed, 15 insertions, 26 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 3892025..bc6d5ce 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1226,12 +1226,6 @@ static int ahci_dma_rw_buf(IDEDMA *dma, int is_write) return 1; } -static int ahci_dma_set_unit(IDEDMA *dma, int unit) -{ - /* only a single unit per link */ - return 0; -} - static void ahci_cmd_done(IDEDMA *dma) { AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); @@ -1258,7 +1252,6 @@ static const IDEDMAOps ahci_dma_ops = { .prepare_buf = ahci_dma_prepare_buf, .commit_buf = ahci_commit_buf, .rw_buf = ahci_dma_rw_buf, - .set_unit = ahci_dma_set_unit, .cmd_done = ahci_cmd_done, }; diff --git a/hw/ide/core.c b/hw/ide/core.c index 0a3d244..7607d03 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -646,6 +646,7 @@ static void dma_buf_commit(IDEState *s, uint32_t tx_bytes) void ide_set_inactive(IDEState *s, bool more) { s->bus->dma->aiocb = NULL; + s->bus->retry_unit = -1; if (s->bus->dma->ops->set_inactive) { s->bus->dma->ops->set_inactive(s->bus->dma, more); } @@ -666,7 +667,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) BlockErrorAction action = blk_get_error_action(s->blk, is_read, error); if (action == BLOCK_ERROR_ACTION_STOP) { - s->bus->dma->ops->set_unit(s->bus->dma, s->unit); + assert(s->bus->retry_unit == s->unit); s->bus->error_status = op; } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (op & IDE_RETRY_DMA) { @@ -799,6 +800,7 @@ static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd) void ide_start_dma(IDEState *s, BlockCompletionFunc *cb) { + s->bus->retry_unit = s->unit; if (s->bus->dma->ops->start_dma) { s->bus->dma->ops->start_dma(s->bus->dma, s, cb); } @@ -2327,11 +2329,11 @@ static const IDEDMAOps ide_dma_nop_ops = { .prepare_buf = ide_nop_int32, .restart_dma = ide_nop, .rw_buf = ide_nop_int, - .set_unit = ide_nop_int, }; static void ide_restart_dma(IDEState *s, enum ide_dma_cmd dma_cmd) { + s->unit = s->bus->retry_unit; s->bus->dma->ops->restart_dma(s->bus->dma); s->io_buffer_index = 0; s->io_buffer_size = 0; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 44cce5b..9630f61 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -436,7 +436,6 @@ struct IDEDMAOps { DMAInt32Func *prepare_buf; DMAu32Func *commit_buf; DMAIntFunc *rw_buf; - DMAIntFunc *set_unit; DMAVoidFunc *restart_dma; DMAStopFunc *set_inactive; DMAVoidFunc *cmd_done; @@ -465,6 +464,7 @@ struct IDEBus { qemu_irq irq; int error_status; + uint8_t retry_unit; }; #define TYPE_IDE_DEVICE "ide-device" diff --git a/hw/ide/macio.c b/hw/ide/macio.c index e7a5c99..a009674 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -572,7 +572,6 @@ static const IDEDMAOps dbdma_ops = { .start_dma = ide_dbdma_start, .prepare_buf = ide_nop_int32, .rw_buf = ide_nop_int, - .set_unit = ide_nop_int, }; static void macio_ide_realizefn(DeviceState *dev, Error **errp) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index cd1bbb0..2b0e886 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -42,7 +42,6 @@ static void bmdma_start_dma(IDEDMA *dma, IDEState *s, { BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma); - bm->unit = s->unit; bm->dma_cb = dma_cb; bm->cur_prd_last = 0; bm->cur_prd_addr = 0; @@ -163,20 +162,11 @@ static int bmdma_rw_buf(IDEDMA *dma, int is_write) return 1; } -static int bmdma_set_unit(IDEDMA *dma, int unit) -{ - BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma); - bm->unit = unit; - - return 0; -} - static void bmdma_set_inactive(IDEDMA *dma, bool more) { BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma); bm->dma_cb = NULL; - bm->unit = -1; if (more) { bm->status |= BM_STATUS_DMAING; } else { @@ -335,6 +325,7 @@ static void ide_bmdma_pre_save(void *opaque) BMDMAState *bm = opaque; uint8_t abused_bits = BM_MIGRATION_COMPAT_STATUS_BITS; + bm->migration_retry_unit = bm->bus->retry_unit; bm->migration_compat_status = (bm->status & ~abused_bits) | (bm->bus->error_status & abused_bits); } @@ -351,6 +342,9 @@ static int ide_bmdma_post_load(void *opaque, int version_id) bm->status = bm->migration_compat_status & ~abused_bits; bm->bus->error_status |= bm->migration_compat_status & abused_bits; } + if (bm->bus->error_status) { + bm->bus->retry_unit = bm->migration_retry_unit; + } return 0; } @@ -389,7 +383,7 @@ static const VMStateDescription vmstate_bmdma = { VMSTATE_UINT32(addr, BMDMAState), VMSTATE_INT64(sector_num, BMDMAState), VMSTATE_UINT32(nsector, BMDMAState), - VMSTATE_UINT8(unit, BMDMAState), + VMSTATE_UINT8(migration_retry_unit, BMDMAState), VMSTATE_END_OF_LIST() }, .subsections = (VMStateSubsection []) { @@ -413,7 +407,7 @@ static int ide_pci_post_load(void *opaque, int version_id) for(i = 0; i < 2; i++) { /* current versions always store 0/1, but older version stored bigger values. We only need last bit */ - d->bmdma[i].unit &= 1; + d->bmdma[i].migration_retry_unit &= 1; ide_bmdma_post_load(&d->bmdma[i], -1); } @@ -454,7 +448,6 @@ static const struct IDEDMAOps bmdma_ops = { .start_dma = bmdma_start_dma, .prepare_buf = bmdma_prepare_buf, .rw_buf = bmdma_rw_buf, - .set_unit = bmdma_set_unit, .restart_dma = bmdma_restart_dma, .set_inactive = bmdma_set_inactive, .reset = bmdma_reset, diff --git a/hw/ide/pci.h b/hw/ide/pci.h index ea4e051..222a163 100644 --- a/hw/ide/pci.h +++ b/hw/ide/pci.h @@ -33,6 +33,8 @@ typedef struct BMDMAState { /* Bit 0-2 and 7: BM status register * Bit 3-6: bus->error_status */ uint8_t migration_compat_status; + uint8_t migration_retry_unit; + struct PCIIDEState *pci_dev; } BMDMAState; @@ -61,8 +63,8 @@ typedef struct PCIIDEState { static inline IDEState *bmdma_active_if(BMDMAState *bmdma) { - assert(bmdma->unit != (uint8_t)-1); - return bmdma->bus->ifs + bmdma->unit; + assert(bmdma->bus->retry_unit != (uint8_t)-1); + return bmdma->bus->ifs + bmdma->bus->retry_unit; } |