Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Nov 2016 05:09:43 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r308906 - in head/sys/dev/hyperv: include vmbus
Message-ID:  <201611210509.uAL59hZo066875@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Mon Nov 21 05:09:43 2016
New Revision: 308906
URL: https://svnweb.freebsd.org/changeset/base/308906

Log:
  hyperv/vmbus: Support transction result busy-wait.
  
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D8488

Modified:
  head/sys/dev/hyperv/include/vmbus_xact.h
  head/sys/dev/hyperv/vmbus/vmbus_xact.c

Modified: head/sys/dev/hyperv/include/vmbus_xact.h
==============================================================================
--- head/sys/dev/hyperv/include/vmbus_xact.h	Mon Nov 21 05:00:51 2016	(r308905)
+++ head/sys/dev/hyperv/include/vmbus_xact.h	Mon Nov 21 05:09:43 2016	(r308906)
@@ -51,6 +51,8 @@ void			vmbus_xact_activate(struct vmbus_
 void			vmbus_xact_deactivate(struct vmbus_xact *xact);
 const void		*vmbus_xact_wait(struct vmbus_xact *xact,
 			    size_t *resp_len);
+const void		*vmbus_xact_busywait(struct vmbus_xact *xact,
+			    size_t *resp_len);
 void			vmbus_xact_wakeup(struct vmbus_xact *xact,
 			    const void *data, size_t dlen);
 void			vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx,

Modified: head/sys/dev/hyperv/vmbus/vmbus_xact.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_xact.c	Mon Nov 21 05:00:51 2016	(r308905)
+++ head/sys/dev/hyperv/vmbus/vmbus_xact.c	Mon Nov 21 05:09:43 2016	(r308906)
@@ -69,6 +69,8 @@ static struct vmbus_xact	*vmbus_xact_all
 static void			vmbus_xact_free(struct vmbus_xact *);
 static struct vmbus_xact	*vmbus_xact_get1(struct vmbus_xact_ctx *,
 				    uint32_t);
+const void			*vmbus_xact_wait1(struct vmbus_xact *, size_t *,
+				    bool);
 
 static struct vmbus_xact *
 vmbus_xact_alloc(struct vmbus_xact_ctx *ctx, bus_dma_tag_t parent_dtag)
@@ -249,7 +251,8 @@ vmbus_xact_deactivate(struct vmbus_xact 
 }
 
 const void *
-vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len)
+vmbus_xact_wait1(struct vmbus_xact *xact, size_t *resp_len,
+    bool can_sleep)
 {
 	struct vmbus_xact_ctx *ctx = xact->x_ctx;
 	const void *resp;
@@ -258,8 +261,14 @@ vmbus_xact_wait(struct vmbus_xact *xact,
 
 	KASSERT(ctx->xc_active == xact, ("xact mismatch"));
 	while (xact->x_resp == NULL) {
-		mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0,
-		    "wxact", 0);
+		if (can_sleep) {
+			mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0,
+			    "wxact", 0);
+		} else {
+			mtx_unlock(&ctx->xc_active_lock);
+			DELAY(1000);
+			mtx_lock(&ctx->xc_active_lock);
+		}
 	}
 	ctx->xc_active = NULL;
 
@@ -271,6 +280,20 @@ vmbus_xact_wait(struct vmbus_xact *xact,
 	return (resp);
 }
 
+const void *
+vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len)
+{
+
+	return (vmbus_xact_wait1(xact, resp_len, true /* can sleep */));
+}
+
+const void *
+vmbus_xact_busywait(struct vmbus_xact *xact, size_t *resp_len)
+{
+
+	return (vmbus_xact_wait1(xact, resp_len, false /* can't sleep */));
+}
+
 static void
 vmbus_xact_save_resp(struct vmbus_xact *xact, const void *data, size_t dlen)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611210509.uAL59hZo066875>