Date: Wed, 27 Jul 2016 05:47:33 +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: r303361 - head/sys/dev/hyperv/vmbus Message-ID: <201607270547.u6R5lXNW055234@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607270547.u6R5lXNW055234>