Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Dec 2016 03:07:58 +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: r310651 - head/sys/dev/hyperv/vmbus
Message-ID:  <201612280307.uBS37wRP051157@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Wed Dec 28 03:07:58 2016
New Revision: 310651
URL: https://svnweb.freebsd.org/changeset/base/310651

Log:
  hyperv/vmbus: Nuke unnecessary critical sections.
  
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D8906

Modified:
  head/sys/dev/hyperv/vmbus/vmbus.c
  head/sys/dev/hyperv/vmbus/vmbus_chan.c
  head/sys/dev/hyperv/vmbus/vmbus_var.h

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c	Wed Dec 28 02:55:26 2016	(r310650)
+++ head/sys/dev/hyperv/vmbus/vmbus.c	Wed Dec 28 03:07:58 2016	(r310651)
@@ -1393,7 +1393,7 @@ cleanup:
 		vmbus_xact_ctx_destroy(sc->vmbus_xc);
 		sc->vmbus_xc = NULL;
 	}
-	free(sc->vmbus_chmap, M_DEVBUF);
+	free(__DEVOLATILE(void *, sc->vmbus_chmap), M_DEVBUF);
 	mtx_destroy(&sc->vmbus_prichan_lock);
 	mtx_destroy(&sc->vmbus_chan_lock);
 
@@ -1480,7 +1480,7 @@ vmbus_detach(device_t dev)
 		sc->vmbus_xc = NULL;
 	}
 
-	free(sc->vmbus_chmap, M_DEVBUF);
+	free(__DEVOLATILE(void *, sc->vmbus_chmap), M_DEVBUF);
 	mtx_destroy(&sc->vmbus_prichan_lock);
 	mtx_destroy(&sc->vmbus_chan_lock);
 

Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c	Wed Dec 28 02:55:26 2016	(r310650)
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c	Wed Dec 28 03:07:58 2016	(r310651)
@@ -775,9 +775,7 @@ vmbus_chan_clrchmap_task(void *xchan, in
 {
 	struct vmbus_channel *chan = xchan;
 
-	critical_enter();
 	chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL;
-	critical_exit();
 }
 
 static void
@@ -1308,15 +1306,17 @@ vmbus_chan_pollcfg_task(void *xarg, int 
 	chan->ch_poll_flags = poll_flags;
 
 	/*
-	 * Disable interrupt from the RX bufring (TX bufring does not
-	 * generate interrupt to VM), and disconnect this channel from
-	 * the channel map to make sure that ISR can not enqueue this
-	 * channel task anymore.
+	 * Disconnect this channel from the channel map to make sure that
+	 * the RX bufring interrupt enabling bit can not be touched, and
+	 * ISR can not enqueue this channel task anymore.  THEN, disable
+	 * interrupt from the RX bufring (TX bufring does not generate
+	 * interrupt to VM).
+	 *
+	 * NOTE: order is critical.
 	 */
-	critical_enter();
-	vmbus_rxbr_intr_mask(&chan->ch_rxbr);
 	chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL;
-	critical_exit();
+	__compiler_membar();
+	vmbus_rxbr_intr_mask(&chan->ch_rxbr);
 
 	/*
 	 * NOTE:
@@ -1380,11 +1380,9 @@ vmbus_chan_polldis_task(void *xchan, int
 	 * Plug this channel back to the channel map and unmask
 	 * the RX bufring interrupt.
 	 */
-	critical_enter();
 	chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan;
 	__compiler_membar();
 	vmbus_rxbr_intr_unmask(&chan->ch_rxbr);
-	critical_exit();
 
 	/*
 	 * Kick start the interrupt task, just in case unmasking

Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed Dec 28 02:55:26 2016	(r310650)
+++ head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed Dec 28 03:07:58 2016	(r310651)
@@ -93,7 +93,7 @@ struct vmbus_softc {
 
 	u_long			*vmbus_rx_evtflags;
 						/* compat evtflgs from host */
-	struct vmbus_channel	**vmbus_chmap;
+	struct vmbus_channel *volatile *vmbus_chmap;
 	struct vmbus_xact_ctx	*vmbus_xc;
 	struct vmbus_pcpu_data	vmbus_pcpu[MAXCPU];
 



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