On Wed, Nov 13, 2019 at 01:41:28AM -0500, Brennan Vincent wrote:
> Hello,
> 
> I have a Wi-Fi USB adapter. urtwn(4) normally works fine, but it's a bit 
> flaky... 
> 
> The issue happens both on 6.6 and on -current.
> 
> When my adapter gets into the bad state, it appears (from dmesg output) that
> the driver is scanning for access points over and over, never
> finding any. When I get into this wedged state, I don't know any way
> to bring the card back up other than unplugging it and re-inserting.
> (`ifconfig urtwn0 down && sleep 10 && sh /etc/netstart urtwn0`
> is no help).
> 
> I am attaching the relevant snippets of the dmesg output
> (Kernel built with URTWN_DEBUG and urtwn_debug level set to 3).
> 
> Another interesting thing is these "RX status=6" error messages in the
> output. Apparently, "6" corresponds to "USBD_CANCELLED"
> in sys/dev/usb/usbdi.h .
> 
> I don't think this is a hardware issue because the device is
> working fine on Ubuntu.
> 
> Please let me know if there is anything more I can do to help debug this.
> I am a beginner with OpenBSD so I'm not sure exactly what is relevant.

Despite our USB issues, there are minor problems with the urtwn(4) for
RTL8188C/RTL8192C:

- we don't need to enable/disable efuse access protection; it may prevent
  incorrect mac address read from efuse.
- disable BB/RF is not needed.

Index: sys/dev/ic/rtwn.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 rtwn.c
--- sys/dev/ic/rtwn.c   25 Apr 2019 01:52:13 -0000      1.46
+++ sys/dev/ic/rtwn.c   16 Nov 2019 09:23:07 -0000
@@ -529,7 +529,9 @@ rtwn_efuse_read(struct rtwn_softc *sc, u
        uint32_t reg;
        int i, len;
 
-       rtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
+       if (!(sc->chip & (RTWN_CHIP_92C | RTWN_CHIP_88C)))
+               rtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
+
        rtwn_efuse_switch_power(sc);
 
        memset(rom, 0xff, size);
@@ -571,7 +573,8 @@ rtwn_efuse_read(struct rtwn_softc *sc, u
                printf("\n");
        }
 #endif
-       rtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
+       if (!(sc->chip & (RTWN_CHIP_92C | RTWN_CHIP_88C)))
+               rtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
 }
 
 void
Index: sys/dev/usb/if_urtwn.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v
retrieving revision 1.84
diff -u -p -u -p -r1.84 if_urtwn.c
--- sys/dev/usb/if_urtwn.c      12 Sep 2019 12:55:07 -0000      1.84
+++ sys/dev/usb/if_urtwn.c      16 Nov 2019 09:23:07 -0000
@@ -1704,21 +1704,6 @@ urtwn_r92c_power_on(struct urtwn_softc *
        urtwn_write_2(sc, R92C_SYS_ISO_CTRL,
            urtwn_read_2(sc, R92C_SYS_ISO_CTRL) & ~R92C_SYS_ISO_CTRL_DIOR);
 
-       /* Initialize MAC. */
-       urtwn_write_1(sc, R92C_APSD_CTRL,
-           urtwn_read_1(sc, R92C_APSD_CTRL) & ~R92C_APSD_CTRL_OFF);
-       for (ntries = 0; ntries < 200; ntries++) {
-               if (!(urtwn_read_1(sc, R92C_APSD_CTRL) &
-                   R92C_APSD_CTRL_OFF_STATUS))
-                       break;
-               DELAY(5);
-       }
-       if (ntries == 200) {
-               printf("%s: timeout waiting for MAC initialization\n",
-                   sc->sc_dev.dv_xname);
-               return (ETIMEDOUT);
-       }
-
        /* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */
        reg = urtwn_read_2(sc, R92C_CR);
        reg |= R92C_CR_HCI_TXDMA_EN | R92C_CR_HCI_RXDMA_EN |

Reply via email to