From owner-svn-src-all@freebsd.org Wed Jul 27 05:47:34 2016 Return-Path: Delivered-To: svn-src-all@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 233BEBA6367; Wed, 27 Jul 2016 05:47:34 +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 00EFD1AE6; Wed, 27 Jul 2016 05:47:33 +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 u6R5lXGt055237; Wed, 27 Jul 2016 05:47:33 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6R5lXNW055234; Wed, 27 Jul 2016 05:47:33 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201607270547.u6R5lXNW055234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 27 Jul 2016 05:47:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303361 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 05:47:34 -0000 Author: sephe Date: Wed Jul 27 05:47:32 2016 New Revision: 303361 URL: https://svnweb.freebsd.org/changeset/base/303361 Log: hyperv/vmbus: Initialize RX/TX bufring mutex at channel creation time MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7312 Modified: head/sys/dev/hyperv/vmbus/hv_ring_buffer.c head/sys/dev/hyperv/vmbus/vmbus_brvar.h head/sys/dev/hyperv/vmbus/vmbus_chan.c Modified: head/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Jul 27 05:38:09 2016 (r303360) +++ head/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Jul 27 05:47:32 2016 (r303361) @@ -198,20 +198,24 @@ hv_ring_buffer_needsig_on_write(uint32_t /** * @brief Initialize the ring buffer. */ -int +void hv_vmbus_ring_buffer_init(hv_vmbus_ring_buffer_info *ring_info, void *buffer, uint32_t buffer_len) { - memset(ring_info, 0, sizeof(hv_vmbus_ring_buffer_info)); - ring_info->ring_buffer = buffer; - ring_info->ring_buffer->br_rindex = 0; - ring_info->ring_buffer->br_windex = 0; - ring_info->ring_data_size = buffer_len - sizeof(struct vmbus_bufring); - mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); +} - return (0); +void +vmbus_br_init(hv_vmbus_ring_buffer_info *ring_info) +{ + mtx_init(&ring_info->ring_lock, "vmbus_br", NULL, MTX_SPIN); +} + +void +vmbus_br_deinit(hv_vmbus_ring_buffer_info *ring_info) +{ + mtx_destroy(&ring_info->ring_lock); } /** @@ -220,7 +224,7 @@ hv_vmbus_ring_buffer_init(hv_vmbus_ring_ void hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info *ring_info) { - mtx_destroy(&ring_info->ring_lock); + /* Do nothing */ } /** Modified: head/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Jul 27 05:38:09 2016 (r303360) +++ head/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Jul 27 05:47:32 2016 (r303361) @@ -49,11 +49,13 @@ void vmbus_br_sysctl_create(struct sysct struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, const char *name); -int hv_vmbus_ring_buffer_init( +void vmbus_br_init(hv_vmbus_ring_buffer_info *ring_info); +void vmbus_br_deinit(hv_vmbus_ring_buffer_info *ring_info); + +void hv_vmbus_ring_buffer_init( hv_vmbus_ring_buffer_info *ring_info, void *buffer, uint32_t buffer_len); - void hv_ring_buffer_cleanup( hv_vmbus_ring_buffer_info *ring_info); Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Jul 27 05:38:09 2016 (r303360) +++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Jul 27 05:47:32 2016 (r303361) @@ -914,6 +914,8 @@ vmbus_chan_alloc(struct vmbus_softc *sc) mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); TAILQ_INIT(&chan->ch_subchans); TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + vmbus_br_init(&chan->ch_rxbr); + vmbus_br_init(&chan->ch_txbr); return chan; } @@ -926,6 +928,8 @@ vmbus_chan_free(struct vmbus_channel *ch /* TODO: asset no longer on the vmbus channel list */ hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); + vmbus_br_deinit(&chan->ch_rxbr); + vmbus_br_deinit(&chan->ch_txbr); free(chan, M_DEVBUF); }