diff options
author | John Snow <jsnow@redhat.com> | 2015-09-17 14:17:04 -0400 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2015-09-17 14:17:04 -0400 |
commit | aaeda4a3c9e4d1d25c65ce8ca98e2de06daf1eec (patch) | |
tree | fd10123de60b8c4e2bbf46bcdd9ca190af577a67 /hw/ide/core.c | |
parent | 16a1b6e97c2a2919fd296db4bea2f9da2ad3cc4d (diff) | |
download | hqemu-aaeda4a3c9e4d1d25c65ce8ca98e2de06daf1eec.zip hqemu-aaeda4a3c9e4d1d25c65ce8ca98e2de06daf1eec.tar.gz |
ide: unify io_buffer_offset increments
IDEState's io_buffer_offset was originally added to keep track of offsets
in AHCI rather exclusively, but it was added to IDEState instead of an
AHCI-specific structure.
AHCI fakes all PIO transfers using DMA and a scatter-gather list. When
the core or atapi layers invoke HBA-specific mechanisms for transfers,
they do not always know that it is being backed by DMA or a sglist, so
this offset is not always updated by the HBA code everywhere.
If we modify it in dma_buf_commit, however, any HBA that needs to use
this offset to manage operating on only part of a sglist will have
access to it.
This will fix ATAPI PIO transfers performed through the AHCI HBA,
which were previously not modifying this value appropriately.
This will fix ATAPI PIO transfers larger than one sector.
Reported-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1440546331-29087-2-git-send-email-jsnow@redhat.com
CC: qemu-stable@nongnu.org
Diffstat (limited to 'hw/ide/core.c')
-rw-r--r-- | hw/ide/core.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index 50449ca..8ba04df 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -591,7 +591,6 @@ static void ide_sector_read_cb(void *opaque, int ret) s->nsector -= n; /* Allow the guest to read the io_buffer */ ide_transfer_start(s, s->io_buffer, n * BDRV_SECTOR_SIZE, ide_sector_read); - s->io_buffer_offset += 512 * n; ide_set_irq(s->bus); } @@ -635,11 +634,12 @@ static void ide_sector_read(IDEState *s) ide_sector_read_cb, s); } -static void dma_buf_commit(IDEState *s, uint32_t tx_bytes) +void dma_buf_commit(IDEState *s, uint32_t tx_bytes) { if (s->bus->dma->ops->commit_buf) { s->bus->dma->ops->commit_buf(s->bus->dma, tx_bytes); } + s->io_buffer_offset += tx_bytes; qemu_sglist_destroy(&s->sg); } @@ -842,7 +842,6 @@ static void ide_sector_write_cb(void *opaque, int ret) n = s->req_nb_sectors; } s->nsector -= n; - s->io_buffer_offset += 512 * n; ide_set_sector(s, ide_get_sector(s) + n); if (s->nsector == 0) { |