aboutsummaryrefslogtreecommitdiff
path: root/dma-helpers.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-06-03 14:17:19 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2013-07-04 17:42:30 +0200
commitf487b677c2dc15786dbe7c61326cc49e7c64daea (patch)
treefedfbfc9a8476c8d76b8723a22e6dc0e4430bda3 /dma-helpers.c
parentcac3c384bb986f06a308e551641284586924813c (diff)
downloadqemu-f487b677c2dc15786dbe7c61326cc49e7c64daea.zip
qemu-f487b677c2dc15786dbe7c61326cc49e7c64daea.tar.gz
qemu-f487b677c2dc15786dbe7c61326cc49e7c64daea.tar.bz2
dma: keep a device alive while it has SGLists
Reviewed-by: Anthony Liguori <aliguori@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'dma-helpers.c')
-rw-r--r--dma-helpers.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dma-helpers.c b/dma-helpers.c
index 5afba47..499550f 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -34,13 +34,16 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t len)
return error;
}
-void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint, AddressSpace *as)
+void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint,
+ AddressSpace *as)
{
qsg->sg = g_malloc(alloc_hint * sizeof(ScatterGatherEntry));
qsg->nsg = 0;
qsg->nalloc = alloc_hint;
qsg->size = 0;
qsg->as = as;
+ qsg->dev = dev;
+ object_ref(OBJECT(dev));
}
void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len)
@@ -57,6 +60,7 @@ void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len)
void qemu_sglist_destroy(QEMUSGList *qsg)
{
+ object_unref(OBJECT(qsg->dev));
g_free(qsg->sg);
memset(qsg, 0, sizeof(*qsg));
}