summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2016-02-26 02:26:19 +0000
committersephe <sephe@FreeBSD.org>2016-02-26 02:26:19 +0000
commit90988c1816c4c962221da2b8a89714543b6d9392 (patch)
tree8bd5a434449dd7cc92b434d25568f30ef304929b
parent91180d20bc4ef6dc63633bb8b84e5c3f27515275 (diff)
downloadFreeBSD-src-90988c1816c4c962221da2b8a89714543b6d9392.zip
FreeBSD-src-90988c1816c4c962221da2b8a89714543b6d9392.tar.gz
hyperv: Use atomic_fetchadd_int to get GPADL id.
Reviewed by: Hongjiang Zhang <honzhan microsoft com> MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5439
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/dev/hyperv/vmbus/hv_channel.c b/sys/dev/hyperv/vmbus/hv_channel.c
index bb777cc..a9b7bd4 100644
--- a/sys/dev/hyperv/vmbus/hv_channel.c
+++ b/sys/dev/hyperv/vmbus/hv_channel.c
@@ -384,17 +384,22 @@ hv_vmbus_channel_establish_gpadl(
hv_vmbus_channel_msg_info* curr;
uint32_t next_gpadl_handle;
- next_gpadl_handle = hv_vmbus_g_connection.next_gpadl_handle;
- atomic_add_int((int*) &hv_vmbus_g_connection.next_gpadl_handle, 1);
+ next_gpadl_handle = atomic_fetchadd_int(
+ &hv_vmbus_g_connection.next_gpadl_handle, 1);
ret = vmbus_channel_create_gpadl_header(
contig_buffer, size, &msg_info, &msg_count);
- if(ret != 0) { /* if(allocation failed) return immediately */
- /* reverse atomic_add_int above */
- atomic_subtract_int((int*)
- &hv_vmbus_g_connection.next_gpadl_handle, 1);
- return ret;
+ if(ret != 0) {
+ /*
+ * XXX
+ * We can _not_ even revert the above incremental,
+ * if multiple GPADL establishments are running
+ * parallelly, decrement the global next_gpadl_handle
+ * is calling for _big_ trouble. A better solution
+ * is to have a 0-based GPADL id bitmap ...
+ */
+ return ret;
}
sema_init(&msg_info->wait_sema, 0, "Open Info Sema");
OpenPOWER on IntegriCloud