Skip to content

Commit a990858

Browse files
philmdstefanhaRH
authored andcommitted
util/vfio-helpers: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD
Simplify qemu_vfio_dma_[un]map() handlers by replacing a pair of qemu_mutex_lock/qemu_mutex_unlock calls by the WITH_QEMU_LOCK_GUARD macro. Reviewed-by: Klaus Jensen <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent cb49dfc commit a990858

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

util/vfio-helpers.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size,
735735
assert(QEMU_PTR_IS_ALIGNED(host, qemu_real_host_page_size));
736736
assert(QEMU_IS_ALIGNED(size, qemu_real_host_page_size));
737737
trace_qemu_vfio_dma_map(s, host, size, temporary, iova);
738-
qemu_mutex_lock(&s->lock);
738+
QEMU_LOCK_GUARD(&s->lock);
739739
mapping = qemu_vfio_find_mapping(s, host, &index);
740740
if (mapping) {
741741
iova0 = mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->host);
@@ -778,7 +778,6 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size,
778778
*iova = iova0;
779779
}
780780
out:
781-
qemu_mutex_unlock(&s->lock);
782781
return ret;
783782
}
784783

@@ -813,14 +812,12 @@ void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host)
813812
}
814813

815814
trace_qemu_vfio_dma_unmap(s, host);
816-
qemu_mutex_lock(&s->lock);
815+
QEMU_LOCK_GUARD(&s->lock);
817816
m = qemu_vfio_find_mapping(s, host, &index);
818817
if (!m) {
819-
goto out;
818+
return;
820819
}
821820
qemu_vfio_undo_mapping(s, m, NULL);
822-
out:
823-
qemu_mutex_unlock(&s->lock);
824821
}
825822

826823
static void qemu_vfio_reset(QEMUVFIOState *s)

0 commit comments

Comments
 (0)