Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2016 15:59:09 +0300
From:      "Andriy Voskoboinyk" <avos@freebsd.org>
To:        "Marcus von Appen" <mva@freebsd.org>
Cc:        current@freebsd.org, freebsd-wireless@freebsd.org
Subject:   Re: rtwn connection stops working on CURRENT
Message-ID:  <op.yi1s0vur4dikkl@localhost>
In-Reply-To: <20160614052401.GA931@athena.sysfault.org>
References:  <20160614052401.GA931@athena.sysfault.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Tue, 14 Jun 2016 08:24:01 +0300 було написано Marcus von Appen  
<mva@freebsd.org>:

Hi!

Try attached patch (adds some busdma synchronization,
unloads data instead of descriptor in rtwn_tx_done() and improves
watchdog logic for a bit).

> Hi,
>
> I'm running into a somewhat weird issue with the rtwn driver
> on CURRENT. It usually works for a couple of minutes (if there's
> not too much of troughput happening) before the downstream and
> upstream rates just "dry up" and the interface stops working.
> It happens faster, if there are multiple connections open at the
> same time, e.g. having a browser open or fetching mail and doing
> a portsnap update.
>
> Once the connection stopped working, dhclient will report the
> following:
>
>   Jun 11 12:22:22 athena dhclient[474]: send_packet: no buffer space  
> available
>   Jun 11 12:24:08 athena last message repeated 4 times
>   ...
>
> wpa_supplicant reports:
>
>   Jun 11 12:22:20 athena wpa_supplicant[335]: wlan0:  
> CTRL-EVENT-DISCONNECTED bssid=... reason=3 locally_generated=1
>   Jun 11 12:22:20 athena wpa_supplicant[335]: wlan0: WPA: 4-Way  
> Handshake failed - pre-shared key may be incorrect
>   Jun 11 12:22:20 athena wpa_supplicant[335]: wlan0:  
> CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="..." auth_failures=8  
> duration=100 reason=WRONG_KEY
>   Jun 11 12:22:20 athena wpa_supplicant[335]: wlan0:  
> CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="..." auth_failures=9  
> duration=152 reason=CONN_FAILED
>
> pciconf -lv:
>
> rtwn0@pci0:3:0:0: class=0x028000 card=0x819510ec chip=0x817610ec  
> rev=0x01 hdr=0x00
>   vendor     = 'Realtek Semiconductor Co., Ltd.'
>   device     = 'RTL8188CE 802.11b/g/n WiFi Adapter'
>   class      = network
>
> An pointers on tracking this issue down and getting it fixed are
> highly appreciated.
>
> Cheers
> Marcus
> _______________________________________________
> freebsd-wireless@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-wireless
> To unsubscribe, send any mail to  
> "freebsd-wireless-unsubscribe@freebsd.org"
[-- Attachment #2 --]
Index: sys/dev/rtwn/if_rtwn.c
===================================================================
--- sys/dev/rtwn/if_rtwn.c	(revision 301778)
+++ sys/dev/rtwn/if_rtwn.c	(working copy)
@@ -586,6 +586,9 @@
 
 	if (rx_ring->desc_dmat != NULL) {
 		if (rx_ring->desc != NULL) {
+			bus_dmamap_sync(rx_ring->desc_dmat,
+			    rx_ring->desc_map,
+			    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(rx_ring->desc_dmat,
 			    rx_ring->desc_map);
 			bus_dmamem_free(rx_ring->desc_dmat, rx_ring->desc,
@@ -600,6 +603,8 @@
 		rx_data = &rx_ring->rx_data[i];
 
 		if (rx_data->m != NULL) {
+			bus_dmamap_sync(rx_ring->data_dmat,
+			    rx_data->map, BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(rx_ring->data_dmat, rx_data->map);
 			m_freem(rx_data->m);
 			rx_data->m = NULL;
@@ -643,6 +648,8 @@
 		device_printf(sc->sc_dev, "could not load desc DMA map\n");
 		goto fail;
 	}
+	bus_dmamap_sync(tx_ring->desc_dmat, tx_ring->desc_map,
+	    BUS_DMASYNC_PREWRITE);
 
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
 	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
@@ -691,6 +698,8 @@
 		    sizeof(desc->nextdescaddr)));
 
 		if (tx_data->m != NULL) {
+			bus_dmamap_sync(tx_ring->data_dmat, tx_data->map,
+			    BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(tx_ring->data_dmat, tx_data->map);
 			m_freem(tx_data->m);
 			tx_data->m = NULL;
@@ -718,6 +727,8 @@
 
 	if (tx_ring->desc_dmat != NULL) {
 		if (tx_ring->desc != NULL) {
+			bus_dmamap_sync(tx_ring->desc_dmat,
+			    tx_ring->desc_map, BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(tx_ring->desc_dmat,
 			    tx_ring->desc_map);
 			bus_dmamem_free(tx_ring->desc_dmat, tx_ring->desc,
@@ -730,6 +741,8 @@
 		tx_data = &tx_ring->tx_data[i];
 
 		if (tx_data->m != NULL) {
+			bus_dmamap_sync(tx_ring->data_dmat, tx_data->map,
+			    BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(tx_ring->data_dmat, tx_data->map);
 			m_freem(tx_data->m);
 			tx_data->m = NULL;
@@ -1761,7 +1774,10 @@
 		if (le32toh(tx_desc->txdw0) & R92C_TXDW0_OWN)
 			continue;
 
-		bus_dmamap_unload(tx_ring->desc_dmat, tx_ring->desc_map);
+		/* Unmap and free mbuf. */
+		bus_dmamap_sync(tx_ring->data_dmat, tx_data->map,
+		    BUS_DMASYNC_POSTWRITE);
+		bus_dmamap_unload(tx_ring->data_dmat, tx_data->map);
 
 		/*
 		 * XXX TODO: figure out whether the transmit succeeded or not.
@@ -1771,8 +1787,10 @@
 		tx_data->ni = NULL;
 		tx_data->m = NULL;
 
-		sc->sc_tx_timer = 0;
-		tx_ring->queued--;
+		if (--tx_ring->queued)
+			sc->sc_tx_timer = 5;
+		else
+			sc->sc_tx_timer = 0;
 	}
 
 	if (tx_ring->queued < (RTWN_TX_LIST_COUNT - 1))

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