Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jul 2012 02:22:17 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238433 - head/sys/dev/ath
Message-ID:  <201207140222.q6E2MHam002875@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sat Jul 14 02:22:17 2012
New Revision: 238433
URL: http://svn.freebsd.org/changeset/base/238433

Log:
  Create an RX queue lock.
  
  Ideally these locks would go away and there'd be a single driver lock,
  like what iwn(4) does.  I'll worry about that later.

Modified:
  head/sys/dev/ath/if_ath_ahb.c
  head/sys/dev/ath/if_ath_pci.c
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_ath_ahb.c
==============================================================================
--- head/sys/dev/ath/if_ath_ahb.c	Sat Jul 14 02:07:51 2012	(r238432)
+++ head/sys/dev/ath/if_ath_ahb.c	Sat Jul 14 02:22:17 2012	(r238433)
@@ -193,11 +193,13 @@ ath_ahb_attach(device_t dev)
 
 	ATH_LOCK_INIT(sc);
 	ATH_PCU_LOCK_INIT(sc);
+	ATH_RX_LOCK_INIT(sc);
 
 	error = ath_attach(AR9130_DEVID, sc);
 	if (error == 0)					/* success */
 		return 0;
 
+	ATH_RX_LOCK_DESTROY(sc);
 	ATH_PCU_LOCK_DESTROY(sc);
 	ATH_LOCK_DESTROY(sc);
 	bus_dma_tag_destroy(sc->sc_dmat);
@@ -238,6 +240,7 @@ ath_ahb_detach(device_t dev)
 	if (sc->sc_eepromdata)
 		free(sc->sc_eepromdata, M_TEMP);
 
+	ATH_RX_LOCK_DESTROY(sc);
 	ATH_PCU_LOCK_DESTROY(sc);
 	ATH_LOCK_DESTROY(sc);
 

Modified: head/sys/dev/ath/if_ath_pci.c
==============================================================================
--- head/sys/dev/ath/if_ath_pci.c	Sat Jul 14 02:07:51 2012	(r238432)
+++ head/sys/dev/ath/if_ath_pci.c	Sat Jul 14 02:22:17 2012	(r238433)
@@ -249,12 +249,14 @@ ath_pci_attach(device_t dev)
 
 	ATH_LOCK_INIT(sc);
 	ATH_PCU_LOCK_INIT(sc);
+	ATH_RX_LOCK_INIT(sc);
 
 	error = ath_attach(pci_get_device(dev), sc);
 	if (error == 0)					/* success */
 		return 0;
 
 	ATH_PCU_LOCK_DESTROY(sc);
+	ATH_RX_LOCK_DESTROY(sc);
 	ATH_LOCK_DESTROY(sc);
 	bus_dma_tag_destroy(sc->sc_dmat);
 bad3:
@@ -294,6 +296,7 @@ ath_pci_detach(device_t dev)
 		free(sc->sc_eepromdata, M_TEMP);
 
 	ATH_PCU_LOCK_DESTROY(sc);
+	ATH_RX_LOCK_DESTROY(sc);
 	ATH_LOCK_DESTROY(sc);
 
 	return (0);

Modified: head/sys/dev/ath/if_athvar.h
==============================================================================
--- head/sys/dev/ath/if_athvar.h	Sat Jul 14 02:07:51 2012	(r238432)
+++ head/sys/dev/ath/if_athvar.h	Sat Jul 14 02:22:17 2012	(r238433)
@@ -425,6 +425,8 @@ struct ath_softc {
 	struct mtx		sc_mtx;		/* master lock (recursive) */
 	struct mtx		sc_pcu_mtx;	/* PCU access mutex */
 	char			sc_pcu_mtx_name[32];
+	struct mtx		sc_rx_mtx;	/* RX access mutex */
+	char			sc_rx_mtx_name[32];
 	struct taskqueue	*sc_tq;		/* private task queue */
 	struct ath_hal		*sc_ah;		/* Atheros HAL */
 	struct ath_ratectrl	*sc_rc;		/* tx rate control support */
@@ -696,6 +698,28 @@ struct ath_softc {
 #define	ATH_PCU_UNLOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_pcu_mtx,	\
 		MA_NOTOWNED)
 
+/*
+ * The RX lock is primarily a(nother) workaround to ensure that the
+ * RX FIFO/list isn't modified by various execution paths.
+ * Even though RX occurs in a single context (the ath taskqueue), the
+ * RX path can be executed via various reset/channel change paths.
+ */
+#define	ATH_RX_LOCK_INIT(_sc) do {\
+	snprintf((_sc)->sc_rx_mtx_name,					\
+	    sizeof((_sc)->sc_rx_mtx_name),				\
+	    "%s RX lock",						\
+	    device_get_nameunit((_sc)->sc_dev));			\
+	mtx_init(&(_sc)->sc_rx_mtx, (_sc)->sc_rx_mtx_name,		\
+		 NULL, MTX_DEF);					\
+	} while (0)
+#define	ATH_RX_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_rx_mtx)
+#define	ATH_RX_LOCK(_sc)		mtx_lock(&(_sc)->sc_rx_mtx)
+#define	ATH_RX_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_rx_mtx)
+#define	ATH_RX_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_rx_mtx,	\
+		MA_OWNED)
+#define	ATH_RX_UNLOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_rx_mtx,	\
+		MA_NOTOWNED)
+
 #define	ATH_TXQ_SETUP(sc, i)	((sc)->sc_txqsetup & (1<<i))
 
 #define	ATH_TXBUF_LOCK_INIT(_sc) do { \



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