FreeBSD Bugzilla – Attachment 239399 Details for
Bug 247528
rtwn(4) RTL8192EU usb wifi dongle can't connect to AP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Also fix ifconfig down/up hang
0001-rtwn-Fix-RTL8192EU-cannot-associate-in-STA-mode.patch (text/plain), 7.00 KB, created by
Cy Schubert
on 2023-01-11 04:28:40 UTC
(
hide
)
Description:
Also fix ifconfig down/up hang
Filename:
MIME Type:
Creator:
Cy Schubert
Created:
2023-01-11 04:28:40 UTC
Size:
7.00 KB
patch
obsolete
>From a34cd4539b44271b70631b87b8f991de624f2cf2 Mon Sep 17 00:00:00 2001 >From: Cy Schubert <cy@FreeBSD.org> >Date: Mon, 9 Jan 2023 12:54:00 -0800 >Subject: [PATCH] rtwn: Fix RTL8192EU cannot associate in STA mode > >On some systems RTL8192EU will fail to associate in STA mode while >others it will work fine. On the systems RTL8192EU fails to associate >in STA mode, it works perfectly fine in AP mode. This points to a USB >timing when selecting a channel while in STA mode. > >While here fix RTL8192EU power off and power on hang for the same reason. > >PR: 247528 >Reported by: Mc James <realmcjames@protonmail.ch>, many >Reviewed by: >Tested by: titus@edc.ro >Approved by: >Concept by: titus@edc.ro >MFC after: >Relnotes: >Differential Revision: >--- > sys/dev/rtwn/rtl8192e/r92e_chan.c | 12 +++++++ > sys/dev/rtwn/rtl8192e/r92e_init.c | 58 ++++++++++++++++++++++++++++-- > sys/dev/rtwn/usb/rtwn_usb_attach.c | 5 +++ > sys/dev/rtwn/usb/rtwn_usb_reg.c | 4 +++ > sys/dev/rtwn/usb/rtwn_usb_var.h | 3 ++ > 5 files changed, 80 insertions(+), 2 deletions(-) > >diff --git a/sys/dev/rtwn/rtl8192e/r92e_chan.c b/sys/dev/rtwn/rtl8192e/r92e_chan.c >index 0211e2883888..d76a25023e08 100644 >--- a/sys/dev/rtwn/rtl8192e/r92e_chan.c >+++ b/sys/dev/rtwn/rtl8192e/r92e_chan.c >@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); > #include <dev/rtwn/rtl8192e/r92e.h> > #include <dev/rtwn/rtl8192e/r92e_reg.h> > #include <dev/rtwn/rtl8192e/r92e_var.h> >+#include <dev/rtwn/usb/rtwn_usb_var.h> > > static int > r92e_get_power_group(struct rtwn_softc *sc, struct ieee80211_channel *c) >@@ -212,9 +213,15 @@ void > r92e_set_chan(struct rtwn_softc *sc, struct ieee80211_channel *c) > { > struct r92e_softc *rs = sc->sc_priv; >+ struct rtwn_usb_softc *uc; > u_int chan; > int i; > >+ if ((uc = RTWN_USB_SOFTC(sc)) != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 1; >+ RTWN_UNLOCK(sc); >+ } > chan = rtwn_chan2centieee(c); > > for (i = 0; i < sc->nrxchains; i++) { >@@ -229,4 +236,9 @@ r92e_set_chan(struct rtwn_softc *sc, struct ieee80211_channel *c) > > /* Set Tx power for this new channel. */ > r92e_set_txpower(sc, c); >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > } >diff --git a/sys/dev/rtwn/rtl8192e/r92e_init.c b/sys/dev/rtwn/rtl8192e/r92e_init.c >index 48a87e6ae98c..8945cc185244 100644 >--- a/sys/dev/rtwn/rtl8192e/r92e_init.c >+++ b/sys/dev/rtwn/rtl8192e/r92e_init.c >@@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$"); > > #include <dev/rtwn/if_rtwn_debug.h> > >+#include <dev/rtwn/usb/rtwn_usb_var.h> >+ > #include <dev/rtwn/rtl8192c/r92c.h> > > #include <dev/rtwn/rtl8192e/r92e.h> >@@ -226,8 +228,15 @@ r92e_power_on(struct rtwn_softc *sc) > if (res != 0) \ > return (EIO); \ > } while(0) >+ struct rtwn_usb_softc *uc; > int ntries; > >+ if ((uc = RTWN_USB_SOFTC(sc)) != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 1; >+ RTWN_UNLOCK(sc); >+ } >+ > if (rtwn_read_4(sc, R92C_SYS_CFG) & R92C_SYS_CFG_TRP_BT_EN) > RTWN_CHK(rtwn_write_1(sc, R92C_LDO_SWR_CTRL, 0xc3)); > else { >@@ -254,6 +263,11 @@ r92e_power_on(struct rtwn_softc *sc) > rtwn_delay(sc, 10); > } > if (ntries == 5000) { >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > device_printf(sc->sc_dev, > "timeout waiting for chip power up\n"); > return (ETIMEDOUT); >@@ -271,8 +285,14 @@ r92e_power_on(struct rtwn_softc *sc) > break; > rtwn_delay(sc, 10); > } >- if (ntries == 5000) >+ if (ntries == 5000) { >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > return (ETIMEDOUT); >+ } > > /* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */ > RTWN_CHK(rtwn_write_2(sc, R92C_CR, 0)); >@@ -283,18 +303,36 @@ r92e_power_on(struct rtwn_softc *sc) > ((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) | > R92C_CR_CALTMR_EN)); > >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > return (0); > } > > void > r92e_power_off(struct rtwn_softc *sc) > { >+ struct rtwn_usb_softc *uc; > int error, ntries; > >+ if ((uc = RTWN_USB_SOFTC(sc)) != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 1; >+ RTWN_UNLOCK(sc); >+ } >+ > /* Stop Rx. */ > error = rtwn_write_1(sc, R92C_CR, 0); >- if (error == ENXIO) /* hardware gone */ >+ if (error == ENXIO) { /* hardware gone */ >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > return; >+ } > > /* Move card to Low Power state. */ > /* Block all Tx queues. */ >@@ -308,6 +346,11 @@ r92e_power_off(struct rtwn_softc *sc) > rtwn_delay(sc, 10); > } > if (ntries == 5000) { >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > device_printf(sc->sc_dev, "%s: failed to block Tx queues\n", > __func__); > return; >@@ -365,6 +408,11 @@ r92e_power_off(struct rtwn_softc *sc) > rtwn_delay(sc, 10); > } > if (ntries == 5000) { >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } > device_printf(sc->sc_dev, "%s: could not turn off MAC\n", > __func__); > return; >@@ -387,4 +435,10 @@ r92e_power_off(struct rtwn_softc *sc) > /* Enable SW LPS. */ > rtwn_setbits_1_shift(sc, R92C_APS_FSMCO, 0, > R92C_APS_FSMCO_APFM_RSM, 1); >+ if (uc != NULL) { >+ RTWN_LOCK(sc); >+ uc->uc_write_delay = 0; >+ RTWN_UNLOCK(sc); >+ } >+ > } >diff --git a/sys/dev/rtwn/usb/rtwn_usb_attach.c b/sys/dev/rtwn/usb/rtwn_usb_attach.c >index 4e881b2d0de5..df04077d78eb 100644 >--- a/sys/dev/rtwn/usb/rtwn_usb_attach.c >+++ b/sys/dev/rtwn/usb/rtwn_usb_attach.c >@@ -372,6 +372,11 @@ rtwn_usb_sysctlattach(struct rtwn_softc *sc) > uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MIN; > if (uc->uc_rx_buf_size > RTWN_USB_RXBUFSZ_MAX) > uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MAX; >+ uc->uc_delay_us = RTWN_USB_DELAY_US_DEF; >+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, >+ "RTWN USB set channel delay microseconds", >+ CTLFLAG_RDTUN, &uc->uc_delay_us, >+ uc->uc_delay_us, str); > } > > static int >diff --git a/sys/dev/rtwn/usb/rtwn_usb_reg.c b/sys/dev/rtwn/usb/rtwn_usb_reg.c >index fad6d04ec5ff..adc9412e68ba 100644 >--- a/sys/dev/rtwn/usb/rtwn_usb_reg.c >+++ b/sys/dev/rtwn/usb/rtwn_usb_reg.c >@@ -91,12 +91,16 @@ rtwn_usb_write_region_1(struct rtwn_softc *sc, uint16_t addr, uint8_t *buf, > int len) > { > usb_device_request_t req; >+ struct rtwn_usb_softc *uc; > > req.bmRequestType = UT_WRITE_VENDOR_DEVICE; > req.bRequest = R92C_REQ_REGS; > USETW(req.wValue, addr); > USETW(req.wIndex, 0); > USETW(req.wLength, len); >+ uc = RTWN_USB_SOFTC(sc); >+ if (uc->uc_write_delay == 1) >+ (sc->sc_delay)(sc,uc->uc_delay_us); > return (rtwn_do_request(sc, &req, buf)); > } > >diff --git a/sys/dev/rtwn/usb/rtwn_usb_var.h b/sys/dev/rtwn/usb/rtwn_usb_var.h >index 7ef214632b12..49716c21961a 100644 >--- a/sys/dev/rtwn/usb/rtwn_usb_var.h >+++ b/sys/dev/rtwn/usb/rtwn_usb_var.h >@@ -28,6 +28,7 @@ > #define RTWN_USB_RXBUFSZ_DEF (24) > #define RTWN_USB_RXBUFSZ_MAX (64) > #define RTWN_USB_TXBUFSZ (16 * 1024) >+#define RTWN_USB_DELAY_US_DEF 1000 > > #define RTWN_IFACE_INDEX 0 > >@@ -79,6 +80,8 @@ struct rtwn_usb_softc { > > int ntx; > int tx_agg_desc_num; >+ int uc_delay_us; >+ int uc_write_delay; > }; > #define RTWN_USB_SOFTC(sc) ((struct rtwn_usb_softc *)(sc)) > >-- >2.39.0 >
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 247528
:
239366
|
239399
|
239429
|
239455
|
240612
|
253233
|
253264
|
253301
|
253303
|
253304