From owner-svn-src-head@freebsd.org Mon Nov 21 05:09:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4184C46C32; Mon, 21 Nov 2016 05:09:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 866551258; Mon, 21 Nov 2016 05:09:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAL59hQ4066877; Mon, 21 Nov 2016 05:09:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAL59hZo066875; Mon, 21 Nov 2016 05:09:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611210509.uAL59hZo066875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 21 Nov 2016 05:09:43 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 05:09:44 -0000 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) {