FreeBSD Bugzilla – Attachment 154328 Details for
Bug 197143
[wpi] [patch]: sync with iwn / OpenBSD wpi
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add separate lock for TX queues
patch-wpi23.diff (text/plain), 5.28 KB, created by
Andriy Voskoboinyk
on 2015-03-15 11:40:04 UTC
(
hide
)
Description:
Add separate lock for TX queues
Filename:
MIME Type:
Creator:
Andriy Voskoboinyk
Created:
2015-03-15 11:40:04 UTC
Size:
5.28 KB
patch
obsolete
>Index: sys/dev/wpi/if_wpi.c >=================================================================== >--- sys/dev/wpi/if_wpi.c (revision 279775) >+++ sys/dev/wpi/if_wpi.c (working copy) >@@ -384,6 +384,7 @@ > } > > WPI_LOCK_INIT(sc); >+ WPI_TXQ_LOCK_INIT(sc); > > /* Allocate DMA memory for firmware transfers. */ > if ((error = wpi_alloc_fwmem(sc)) != 0) { >@@ -679,6 +680,7 @@ > if_free(ifp); > > DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); >+ WPI_TXQ_LOCK_DESTROY(sc); > WPI_LOCK_DESTROY(sc); > return 0; > } >@@ -2151,6 +2153,7 @@ > sc->rxq.update = 0; > wpi_update_rx_ring(sc); > } >+ WPI_TXQ_LOCK(sc); > for (qid = 0; qid < WPI_DRV_NTXQUEUES; qid++) { > struct wpi_tx_ring *ring = &sc->txq[qid]; > >@@ -2159,6 +2162,7 @@ > wpi_update_tx_ring(sc, ring); > } > } >+ WPI_TXQ_UNLOCK(sc); > > WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ); > } >@@ -2220,11 +2224,13 @@ > wpi_nic_unlock(sc); > /* Dump driver status (TX and RX rings) while we're here. */ > printf("driver status:\n"); >+ WPI_TXQ_LOCK(sc); > for (i = 0; i < WPI_DRV_NTXQUEUES; i++) { > struct wpi_tx_ring *ring = &sc->txq[i]; > printf(" tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n", > i, ring->qid, ring->cur, ring->queued); > } >+ WPI_TXQ_UNLOCK(sc); > printf(" rx ring: cur=%d\n", sc->rxq.cur); > } > >@@ -2302,8 +2308,16 @@ > > WPI_LOCK_ASSERT(sc); > >+ WPI_TXQ_LOCK(sc); >+ > DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); > >+ if (sc->txq_active == 0) { >+ /* wpi_stop() was called */ >+ error = ENETDOWN; >+ goto fail; >+ } >+ > wh = mtod(buf->m, struct ieee80211_frame *); > hdrlen = ieee80211_anyhdrsize(wh); > totlen = buf->m->m_pkthdr.len; >@@ -2336,8 +2350,7 @@ > if (error != 0 && error != EFBIG) { > device_printf(sc->sc_dev, > "%s: can't map mbuf (error %d)\n", __func__, error); >- m_freem(buf->m); >- return error; >+ goto fail; > } > if (error != 0) { > /* Too many DMA segments, linearize mbuf. */ >@@ -2345,8 +2358,8 @@ > if (m1 == NULL) { > device_printf(sc->sc_dev, > "%s: could not defrag mbuf\n", __func__); >- m_freem(buf->m); >- return ENOBUFS; >+ error = ENOBUFS; >+ goto fail; > } > buf->m = m1; > >@@ -2356,8 +2369,7 @@ > device_printf(sc->sc_dev, > "%s: can't map mbuf (error %d)\n", __func__, > error); >- m_freem(buf->m); >- return error; >+ goto fail; > } > } > >@@ -2400,7 +2412,17 @@ > > DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); > >+ WPI_TXQ_UNLOCK(sc); >+ > return 0; >+ >+fail: m_freem(buf->m); >+ >+ DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__); >+ >+ WPI_TXQ_UNLOCK(sc); >+ >+ return error; > } > > /* >@@ -2867,8 +2889,16 @@ > bus_addr_t paddr; > int totlen, error; > >+ WPI_TXQ_LOCK(sc); >+ > DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); > >+ if (sc->txq_active == 0) { >+ /* wpi_stop() was called */ >+ error = 0; >+ goto fail; >+ } >+ > if (async == 0) > WPI_LOCK_ASSERT(sc); > >@@ -2888,17 +2918,21 @@ > > if (size > sizeof cmd->data) { > /* Command is too large to fit in a descriptor. */ >- if (totlen > MCLBYTES) >- return EINVAL; >+ if (totlen > MCLBYTES) { >+ error = EINVAL; >+ goto fail; >+ } > m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE); >- if (m == NULL) >- return ENOMEM; >+ if (m == NULL) { >+ error = ENOMEM; >+ goto fail; >+ } > cmd = mtod(m, struct wpi_tx_cmd *); > error = bus_dmamap_load(ring->data_dmat, data->map, cmd, > totlen, wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); > if (error != 0) { > m_freem(m); >- return error; >+ goto fail; > } > data->m = m; > } else { >@@ -2932,6 +2966,8 @@ > > DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); > >+ WPI_TXQ_UNLOCK(sc); >+ > if (async) { > sc->flags &= ~WPI_FLAG_BUSY; > return 0; >@@ -2938,6 +2974,12 @@ > } > > return mtx_sleep(cmd, &sc->sc_mtx, PCATCH, "wpicmd", hz); >+ >+fail: DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__); >+ >+ WPI_TXQ_UNLOCK(sc); >+ >+ return error; > } > > /* >@@ -4817,6 +4859,7 @@ > } > > /* Configure adapter now that it is ready. */ >+ sc->txq_active = 1; > if ((error = wpi_config(sc)) != 0) { > device_printf(sc->sc_dev, > "%s: could not configure device, error %d\n", __func__, >@@ -4859,6 +4902,10 @@ > > WPI_LOCK_ASSERT(sc); > >+ WPI_TXQ_LOCK(sc); >+ sc->txq_active = 0; >+ WPI_TXQ_UNLOCK(sc); >+ > sc->sc_scan_timer = 0; > sc->sc_tx_timer = 0; > callout_stop(&sc->watchdog_to); >Index: sys/dev/wpi/if_wpivar.h >=================================================================== >--- sys/dev/wpi/if_wpivar.h (revision 279775) >+++ sys/dev/wpi/if_wpivar.h (working copy) >@@ -163,6 +163,9 @@ > struct wpi_shared *shared; > > struct wpi_tx_ring txq[WPI_NTXQUEUES]; >+ struct mtx txq_mtx; >+ uint32_t txq_active; >+ > struct wpi_rx_ring rxq; > > /* TX Thermal Callibration. */ >@@ -222,6 +225,8 @@ > char domain[4]; /* Regulatory domain. */ > }; > >+/* WPI_LOCK > WPI_TXQ_LOCK */ >+ > #define WPI_LOCK_INIT(_sc) \ > mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ > MTX_NETWORK_LOCK, MTX_DEF) >@@ -229,3 +234,9 @@ > #define WPI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) > #define WPI_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) > #define WPI_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx) >+ >+#define WPI_TXQ_LOCK_INIT(_sc) \ >+ mtx_init(&(_sc)->txq_mtx, "txq/cmdq lock", NULL, MTX_DEF) >+#define WPI_TXQ_LOCK(_sc) mtx_lock(&(_sc)->txq_mtx) >+#define WPI_TXQ_UNLOCK(_sc) mtx_unlock(&(_sc)->txq_mtx) >+#define WPI_TXQ_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->txq_mtx)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 197143
:
152282
|
152662
|
152977
|
153911
|
153977
|
153983
|
153985
|
153999
|
154000
|
154002
|
154006
|
154007
|
154009
|
154010
|
154011
|
154013
|
154015
|
154016
|
154017
|
154019
|
154020
|
154021
|
154022
|
154024
|
154026
|
154030
|
154032
|
154033
| 154328 |
154329
|
154330
|
154332
|
154334
|
154335
|
154336
|
154337
|
154338
|
154340
|
154341
|
154343
|
154346
|
154347
|
154348
|
154349
|
154350
|
154351
|
154352
|
154353
|
154354
|
154355
|
154356
|
154357
|
154358
|
154359
|
154360
|
154361
|
154362
|
154363
|
154364
|
154365
|
154366
|
154368
|
154369
|
154370
|
154371
|
154372
|
154373
|
154374
|
154375
|
154378
|
154379
|
154380
|
154381
|
154382
|
154383
|
154384
|
155332
|
155333
|
156164
|
156165
|
156166
|
156167
|
156168
|
156169
|
156170
|
156171
|
156172
|
156173
|
156174
|
156175
|
156176
|
156177
|
156178
|
156179
|
156180
|
156181
|
156182
|
156183
|
156184
|
156185
|
156186
|
156187
|
156188
|
156189
|
156190
|
156191
|
156192
|
156193
|
156194
|
156195