[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-bugs
Subject: Re: ure0: usb error on tx: IN_PROGRESS
From: Marcus Glocker <marcus () nazgul ! ch>
Date: 2021-07-22 18:49:34
Message-ID: 20210722204934.62879770 () imac ! nazgul ! ch
[Download RAW message or body]
On Thu, 22 Jul 2021 11:25:00 -0300
Adrian Ali <adrianali@fortix.com.ar> wrote:
> > On Thu, 22 Jul 2021 07:55:18 +0200
> > Marcus Glocker <marcus@nazgul.ch> wrote:
> >
> > > On Wed, 21 Jul 2021 19:23:18 -0300
> > > Adrian Ali <adrianali@fortix.com.ar> wrote:
> > >
> > > > > On Wed, 21 Jul 2021 13:46:54 -0300
> > > > > Adrian Ali <adrianali@fortix.com.ar> wrote:
> > > > >
> > > > > > On Wed, 21 Jul 2021 08:40:34 +0200
> > > > > > Marcus Glocker <marcus@nazgul.ch> wrote:
> > > > > >
> > > > > > > Does this diff fix the issue?
> > > > > > >
> > > > > > >
> > > > > > > Index: if_ure.c
> > > > > > > ===============================================================
> > > > > > > RCS file: /cvs/src/sys/dev/usb/if_ure.c,v
> > > > > > > retrieving revision 1.24
> > > > > > > diff -u -p -u -p -r1.24 if_ure.c
> > > > > > > --- if_ure.c 15 Apr 2021 02:23:17 -0000 1.24
> > > > > > > +++ if_ure.c 21 Jul 2021 14:15:10 -0000
> > > > > > > @@ -435,6 +435,9 @@ ure_miibus_statchg(struct device
> > > > > > > *dev)
> > > > > > > /* Lost link, do nothing. */
> > > > > > > if ((sc->ure_flags & URE_FLAG_LINK)
> > > > > > >== 0)
> > > > > > > return;
> > > > > > > +
> > > > > > > + /* Enable transmit and receive. */
> > > > > > > + URE_SETBIT_1(sc, URE_PLA_CR,
> > > > > > > URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE);
> > > > > > > }
> > > > > > >
> > > > > > > int
> > > > > >
> > > > > > No, test steps:
> > > > > >
> > > > > > Start computer:
> > > > > >
> > > > > > # dmesg | grep ure0
> > > > > > ure0 at uhub0 port 2 configuration 1 interface 0 "TP-LINK
> > > > > > USB 10/100 LAN" rev 2.10/20.00 addr 3
> > > > > > ure0: RTL8152 (0x4c10), address 7c:c2:c6:1a:37:01
> > > > > > rlphy0 at ure0 phy 0: RTL8201E 10/100 PHY, rev. 2
> > > > > >
> > > > > > # ifconfig ure0
> > > > > > ure0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
> > > > > > lladdr 7c:c2:c6:1a:37:01
> > > > > > index 5 priority 0 llprio 3
> > > > > > media: Ethernet autoselect
> > > > > >
> (100baseTX
> > > > > >full-duplex) status: active
> > > > > >
> > > > > > Add IP configuration in device:
> > > > > >
> > > > > > # ifconfig ure0 debug
> > > > > > # ifconfig ure0 192.168.47.1/24
> > > > > >
> > > > > > # ifconfig ure0
> > > > > > ure0:
> > > > > > flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > > > index 5 priority 0 llprio 3
> > > > > > media: Ethernet autoselect
> > > > > >
> (100baseTX
> > > > > >full-duplex) status: active
> > > > > > inet 192.168.47.1 netmask
> > > > > >
> 0xffffff00 broadcast
> > > > > >
> > > > > 192.168.47.255
> > > > > >
> > > > > > Test ping, it works:
> > > > > >
> > > > > > # ping -c3 192.168.47.2
> > > > > > PING 192.168.47.2 (192.168.47.2): 56 data bytes
> > > > > > 64 bytes from 192.168.47.2: icmp_seq=0 ttl=255 time=0.749
> > > > > > ms 64 bytes from 192.168.47.2: icmp_seq=1 ttl=255
> > > > > > time=0.779 ms 64 bytes from 192.168.47.2: icmp_seq=2
> > > > > > ttl=255 time=0.836 ms
> > > > > >
> > > > > > --- 192.168.47.2 ping statistics ---
> > > > > > 3 packets transmitted, 3 packets received, 0.0% packet loss
> > > > > > round-trip min/avg/max/std-dev = 0.749/0.788/0.836/0.036 ms
> > > > > >
> > > > > > unplug cable:
> > > > > >
> > > > > > # ifconfig ure0
> > > > > > ure0:
> > > > > > flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > > > index 5 priority 0 llprio 3
> > > > > > media: Ethernet autoselect
> > > > > >(none) status: no carrier
> > > > > > inet 192.168.47.1 netmask
> > > > > >
> 0xffffff00 broadcast
> > > > > >
> > > > 192.168.47.255
> > > > > >
> > > > > > plug in cable:
> > > > > >
> > > > > > # ifconfig ure0
> > > > > > ure0:
> > > > > > flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > > > index 5 priority 0 llprio 3
> > > > > > media: Ethernet autoselect
> > > > > >
> (100baseTX
> > > > > >full-duplex) status: active
> > > > > > inet 192.168.47.1 netmask
> > > > > >
> 0xffffff00 broadcast
> > > > > >
> > > > 192.168.47.255
> > > > > >
> > > > > > Test ping, does not work:
> > > > > >
> > > > > > # ping -c3 192.168.47.2
> > > > > > PING 192.168.47.2 (192.168.47.2): 56 data bytes
> > > > > >
> > > > > > --- 192.168.47.2 ping statistics ---
> > > > > > 3 packets transmitted, 0 packets received, 100.0% packet
> > > > > > loss
> > > > > >
> > > > > > log:
> > > > > >
> > > > > > Jul 21 13:10:02 neurus /bsd: ure0: usb error on tx:
> > > > > > IN_PROGRESS Jul 21 13:10:02 neurus /bsd:
> > > > > > usb_insert_transfer: xfer=0xfffffd821eeb6c08 not free
> > > > >
> > > > > Um, interesting. I could get my hands on a RTL8153 in the
> > > > > meantime, and there the diff fixes the issue. With the
> > > > > RTL8153 I can see that after the cable gets unplugged, RX/TX
> > > > > is getting disabled on the chip. I have assumed that would
> > > > > also apply to the other RTL815x chip sets.
> > > > >
> > > > > If you want to run this diff (it does basically the same but
> > > > > with more debug output), and send back the dmesg, then we
> > > > > could at least see the RTL8152 behaviour related to the
> > > > > RX/TX register.
> > > >
> > > > Hi, dmesg with this diff :
> > > >
> > > > 1. Start computer:
> > > >
> > > > # dmesg | grep ure0
> > > > ure0 at uhub0 port 2 configuration 1 interface 0 "TP-LINK USB
> > > > 10/100 LAN" rev 2.10/20.00 addr 3
> > > > ure0: RTL8152 (0x4c10), address 7c:c2:c6:1a:37:01
> > > > rlphy0 at ure0 phy 0: RTL8201E 10/100 PHY, rev. 2
> > > >
> > > > # ifconfig ure0
> > > > ure0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
> > > > lladdr 7c:c2:c6:1a:37:01
> > > > index 5 priority 0 llprio 3
> > > > media: Ethernet autoselect (100baseTX
> > > >full-duplex) status: active
> > > >
> > > > 2. Add IP configuration in device:
> > > >
> > > > # ifconfig ure0 debug
> > > > # ifconfig ure0 192.168.47.1/24
> > > >
> > > > dmesg:
> > > >
> > > > Jul 21 19:00:54 neurus /bsd: ure_check_trx_enabled: val=0xc:
> > > > RX-ON TX-ON Jul 21 19:00:56 neurus last message repeated 2
> > > > times
> > > >
> > > > # ifconfig ure0
> > > > ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > index 5 priority 0 llprio 3
> > > > media: Ethernet autoselect (100baseTX
> > > >full-duplex) status: active
> > > > inet 192.168.47.1 netmask 0xffffff00 broadcast
> > > > 192.168.47.255
> > > >
> > > > 3. Test ping, it works:
> > > >
> > > > # ping -c3 192.168.47.2
> > > > PING 192.168.47.2 (192.168.47.2): 56 data bytes
> > > > 64 bytes from 192.168.47.2: icmp_seq=0 ttl=255 time=1.594 ms
> > > > 64 bytes from 192.168.47.2: icmp_seq=1 ttl=255 time=0.783 ms
> > > > 64 bytes from 192.168.47.2: icmp_seq=2 ttl=255 time=0.795 ms
> > > >
> > > > --- 192.168.47.2 ping statistics ---
> > > > 3 packets transmitted, 3 packets received, 0.0% packet loss
> > > > round-trip min/avg/max/std-dev = 0.783/1.057/1.594/0.380 ms
> > > >
> > > > 4. Unplug cable:
> > > >
> > > > # ifconfig ure0
> > > > ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > index 5 priority 0 llprio 3
> > > > media: Ethernet autoselect (none)
> > > > status: no carrier
> > > > inet 192.168.47.1 netmask 0xffffff00 broadcast
> > > > 192.168.47.255
> > > >
> > > > 5. Plug in cable:
> > > >
> > > > dmesg:
> > > >
> > > > Jul 21 19:04:01 neurus /bsd: ure_check_trx_enabled: val=0x0:
> > > > Jul 21 19:04:01 neurus /bsd: ure_check_trx_enabled: val=0xc:
> > > > RX-ON TX-ON
> > > >
> > > > # ifconfig ure0
> > > > ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST>
> > > > mtu 1500 lladdr 7c:c2:c6:1a:37:01
> > > > index 5 priority 0 llprio 3
> > > > media: Ethernet autoselect (100baseTX
> > > >full-duplex) status: active
> > > > inet 192.168.47.1 netmask 0xffffff00 broadcast
> > > > 192.168.47.255
> > > >
> > > > 6. Test ping, does not work:
> > > >
> > > > # ping -c3 192.168.47.2
> > > > PING 192.168.47.2 (192.168.47.2): 56 data bytes
> > > >
> > > > --- 192.168.47.2 ping statistics ---
> > > > 3 packets transmitted, 0 packets received, 100.0% packet loss
> > > >
> > > > dmesg:
> > > >
> > > > Jul 21 19:04:51 neurus /bsd: ure0: usb error on tx: IN_PROGRESS
> > > > Jul 21 19:04:52 neurus /bsd: usb_insert_transfer:
> > > > xfer=0xfffffd821eeb6c08 not free
> > >
> > > Thanks for checking. So you see the same behavior, and the diff
> > > also re-establishes the RX/TX state on the device after the
> > > cable re-plug, but other than on the RTL8153, the RTL8152 still
> > > can't send out data afterwards.
> > >
> > > I'm afraid without having such a device here I won't be able to
> > > help much further. It will be too much try and error ...
> >
> > Last try :-)
> >
> > This diff also applies the RTL8152 specific media settings on the
> > device. It still works fine for the RTL8153. Please only apply
> > this diff when testing.
> >
> >
> > Index: if_ure.c
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/usb/if_ure.c,v
> > retrieving revision 1.24
> > diff -u -p -u -p -r1.24 if_ure.c
> > --- if_ure.c 15 Apr 2021 02:23:17 -0000 1.24
> > +++ if_ure.c 22 Jul 2021 07:57:23 -0000
> > @@ -183,6 +183,7 @@ void ure_xfer_list_free(struct
> > ure_soft
> > void ure_tick_task(void *);
> > void ure_tick(void *);
> >
> > +void ure_ifmedia_init(struct ifnet *);
> > int ure_ifmedia_upd(struct ifnet *);
> > void ure_ifmedia_sts(struct ifnet *, struct ifmediareq *);
> > void ure_add_media_types(struct ure_softc *);
> > @@ -435,6 +436,70 @@ ure_miibus_statchg(struct device *dev)
> > /* Lost link, do nothing. */
> > if ((sc->ure_flags & URE_FLAG_LINK) == 0)
> > return;
> > +
> > + /*
> > + * After a link change the media settings are getting reset
> > on the
> > + * hardware, and need to be re-initialized again for
> > communication
> > + * to continue work.
> > + */
> > + ure_ifmedia_init(ifp);
> > +}
> > +
> > +void
> > +ure_ifmedia_init(struct ifnet *ifp)
> > +{
> > + struct ure_softc *sc = ifp->if_softc;
> > + uint32_t reg = 0;
> > +
> > + /* Set MAC address. */
> > + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA,
> URE_CRWECR_CONFIG);
> > + ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA |
> URE_BYTE_EN_SIX_BYTES,
> > + sc->ure_ac.ac_enaddr, 8);
> > + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA,
> URE_CRWECR_NORAML);
> > +
> > + if (!(sc->ure_flags & URE_FLAG_8152)) {
> > + reg = sc->ure_rxbufsz - URE_FRAMELEN(ifp->if_mtu) -
> > + sizeof(struct ure_rxpkt) - URE_RX_BUF_ALIGN;
> > + if (sc->ure_flags & (URE_FLAG_8153B |
> > URE_FLAG_8156)) {
> > + ure_write_2(sc, URE_USB_RX_EARLY_SIZE,
> URE_MCU_TYPE_USB,
> > + reg / 8);
> > +
> > + ure_write_2(sc, URE_USB_RX_EARLY_AGG,
> URE_MCU_TYPE_USB,
> > + (sc->ure_flags & URE_FLAG_8153B) ? 16 :
> > 80);
> > + ure_write_2(sc, URE_USB_PM_CTRL_STATUS,
> > + URE_MCU_TYPE_USB, 1875);
> > + } else {
> > + ure_write_2(sc, URE_USB_RX_EARLY_SIZE,
> URE_MCU_TYPE_USB,
> > + reg / 4);
> > + switch (sc->ure_udev->speed) {
> > + case USB_SPEED_SUPER:
> > + reg = URE_COALESCE_SUPER / 8;
> > + break;
> > + case USB_SPEED_HIGH:
> > + reg = URE_COALESCE_HIGH / 8;
> > + break;
> > + default:
> > + reg = URE_COALESCE_SLOW / 8;
> > + break;
> > + }
> > + ure_write_2(sc, URE_USB_RX_EARLY_AGG,
> URE_MCU_TYPE_USB,
> > + reg);
> > + }
> > + }
> > +
> > + /* Reset the packet filter. */
> > + URE_CLRBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
> URE_FMC_FCR_MCU_EN);
> > + URE_SETBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
> URE_FMC_FCR_MCU_EN);
> > +
> > + /* Enable transmit and receive. */
> > + URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE |
> URE_CR_TE);
> > +
> > + if (sc->ure_flags & (URE_FLAG_8153B | URE_FLAG_8156)) {
> > + ure_write_1(sc, URE_USB_UPT_RXDMA_OWN,
> > URE_MCU_TYPE_USB,
> > + URE_OWN_UPDATE | URE_OWN_CLEAR);
> > + }
> > +
> > + URE_CLRBIT_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA,
> URE_RXDY_GATED_EN);
> > }
> >
> > int
> > @@ -721,7 +786,6 @@ ure_init(void *xsc)
> > struct ure_chain *c;
> > struct ifnet *ifp = &sc->ure_ac.ac_if;
> > usbd_status err;
> > - uint32_t reg = 0;
> > int s, i;
> >
> > s = splnet();
> > @@ -754,55 +818,8 @@ ure_init(void *xsc)
> > SLIST_INSERT_HEAD(&sc->ure_cdata.ure_tx_free,
> > &sc->ure_cdata.ure_tx_chain[i], uc_list);
> >
> > - /* Set MAC address. */
> > - ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA,
> URE_CRWECR_CONFIG);
> > - ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA |
> URE_BYTE_EN_SIX_BYTES,
> > - sc->ure_ac.ac_enaddr, 8);
> > - ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA,
> URE_CRWECR_NORAML);
> > -
> > - if (!(sc->ure_flags & URE_FLAG_8152)) {
> > - reg = sc->ure_rxbufsz - URE_FRAMELEN(ifp->if_mtu) -
> > - sizeof(struct ure_rxpkt) - URE_RX_BUF_ALIGN;
> > - if (sc->ure_flags & (URE_FLAG_8153B |
> > URE_FLAG_8156)) {
> > - ure_write_2(sc, URE_USB_RX_EARLY_SIZE,
> URE_MCU_TYPE_USB,
> > - reg / 8);
> > -
> > - ure_write_2(sc, URE_USB_RX_EARLY_AGG,
> URE_MCU_TYPE_USB,
> > - (sc->ure_flags & URE_FLAG_8153B) ? 16 :
> > 80);
> > - ure_write_2(sc, URE_USB_PM_CTRL_STATUS,
> > - URE_MCU_TYPE_USB, 1875);
> > - } else {
> > - ure_write_2(sc, URE_USB_RX_EARLY_SIZE,
> URE_MCU_TYPE_USB,
> > - reg / 4);
> > - switch (sc->ure_udev->speed) {
> > - case USB_SPEED_SUPER:
> > - reg = URE_COALESCE_SUPER / 8;
> > - break;
> > - case USB_SPEED_HIGH:
> > - reg = URE_COALESCE_HIGH / 8;
> > - break;
> > - default:
> > - reg = URE_COALESCE_SLOW / 8;
> > - break;
> > - }
> > - ure_write_2(sc, URE_USB_RX_EARLY_AGG,
> URE_MCU_TYPE_USB,
> > - reg);
> > - }
> > - }
> > -
> > - /* Reset the packet filter. */
> > - URE_CLRBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
> URE_FMC_FCR_MCU_EN);
> > - URE_SETBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
> URE_FMC_FCR_MCU_EN);
> > -
> > - /* Enable transmit and receive. */
> > - URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE |
> URE_CR_TE);
> > -
> > - if (sc->ure_flags & (URE_FLAG_8153B | URE_FLAG_8156)) {
> > - ure_write_1(sc, URE_USB_UPT_RXDMA_OWN,
> > URE_MCU_TYPE_USB,
> > - URE_OWN_UPDATE | URE_OWN_CLEAR);
> > - }
> > -
> > - URE_CLRBIT_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA,
> URE_RXDY_GATED_EN);
> > + /* Setup MAC address, and enable TX/RX. */
> > + ure_ifmedia_init(ifp);
> >
> > /* Load the multicast filter. */
> > ure_iff(sc);
> >
> >
> >
> >
>
> Hi, thank you very much Marcus for your help, I understand that it is
> very difficult without having the device. Apply the diff and the bug
> persists:
Aw, pity :-(
Stuart, just out of interest; Does the diff fix the issue on your
RTL8153B by any chance?
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic