diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2015-07-29 21:27:48 +0200 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2015-07-31 16:38:50 -0400 |
commit | 0e826a061a3e8e8485488a7da02cc139fc07d620 (patch) | |
tree | 52586b7e1d3fadbec72080d4c9724c183b5ed9e8 /hw/ide | |
parent | cb48f67ad8c7b33c617d4f8144a27706e69fd688 (diff) |
macio: re-add TRIM support
Commit bd4214fc dropped TRIM support by mistake. Given it is still
advertised to the host when using a drive with discard=on, this cause
the IDE bus to hang when the host issues a TRIM command.
This patch fixes that by re-adding the TRIM code, ported to the new
new DMA implementation.
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: John Snow <jsnow@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-id: 1438198068-32428-1-git-send-email-aurelien@aurel32.net
Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'hw/ide')
-rw-r--r-- | hw/ide/macio.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/hw/ide/macio.c b/hw/ide/macio.c index a55a479da6..66ac2baa94 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -208,6 +208,33 @@ static void pmac_dma_write(BlockBackend *blk, cb, io); } +static void pmac_dma_trim(BlockBackend *blk, + int64_t offset, int bytes, + void (*cb)(void *opaque, int ret), void *opaque) +{ + DBDMA_io *io = opaque; + MACIOIDEState *m = io->opaque; + IDEState *s = idebus_active_if(&m->bus); + dma_addr_t dma_addr, dma_len; + void *mem; + + qemu_iovec_destroy(&io->iov); + qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1); + + dma_addr = io->addr; + dma_len = io->len; + mem = dma_memory_map(&address_space_memory, dma_addr, &dma_len, + DMA_DIRECTION_TO_DEVICE); + + qemu_iovec_add(&io->iov, mem, io->len); + s->io_buffer_size -= io->len; + s->io_buffer_index += io->len; + io->len = 0; + + m->aiocb = ide_issue_trim(blk, (offset >> 9), &io->iov, (bytes >> 9), + cb, io); +} + static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) { DBDMA_io *io = opaque; @@ -313,6 +340,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) pmac_dma_write(s->blk, offset, io->len, pmac_ide_transfer_cb, io); break; case IDE_DMA_TRIM: + pmac_dma_trim(s->blk, offset, io->len, pmac_ide_transfer_cb, io); break; } |