https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252165

--- Comment #24 from Ali Abdallah <ali.abdal...@suse.com> ---
Created attachment 236901
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=236901&action=edit
dtrace ure usb traces

I got another machine on which I didn't apply the workaround, running 13.1,
with a USB Lan adapter that uses if_ure, I used the following dtrace probes.

dtrace -n
'fbt:miibus:mii_pollstat:*,fbt:uether:ue_tick_task:*,fbt:if_ure:ure_tick:*,fbt:if_ure:ure_ifmedia_sts:*,fbt:miibus:mii_tick:*,fbt:miibus:miibus_linkchg:*,
fbt:usb:* { printf("%p", curthread); }'

You can see from the attached debug log (numbered lines)

1  48573            ure_ifmedia_sts:entry fffffe00dc75c720
1  48475               mii_pollstat:entry fffffe00dc75c720

But before exit entry of re_ifmedia_sts:return of thread fffffe00dc75c720, you
can see:

1052   0  48573            ure_ifmedia_sts:entry fffffe00e00271e0
1053   2  27791        usb_command_wrapper:entry fffffe0082a17ac0
1054   2  27738      usbd_callback_wrapper:entry fffffe0082a17ac0
1055   0  48475               mii_pollstat:entry fffffe00e00271e0

And that exactly when the link up/down happened.

So thread fffffe00e00271e0 managed to go ahead and call mii_pollstat, acquiring
the sc mutex, despite that thread fffffe00dc75c720 didn't release it yet, you
can see that the return from "polling the media state" on thread
fffffe00dc75c720 comes way after the ure_ifmedia_sts:entry of thread
fffffe00e00271e0

1517   3  48476              mii_pollstat:return fffffe00dc75c720
1518   3  48574           ure_ifmedia_sts:return fffffe00dc75c720

__snip if_ure__ 

ure_ifmedia_sts
{
  ...
  URE_LOCK(sc);                                                                 
  mii_pollstat(mii);
  ifmr->ifm_active = mii->mii_media_active;
  ifmr->ifm_status = mii->mii_media_status;
  URE_UNLOCK(sc);
}
__snip__

The mutex locked/released by URE_LOCK, is the same mutex used in if_ure, USB
xfer and USB transfer, so I guess something is not playing well in the
release/acquire sequence...

Will try if time permits to dig more into the USB transfer/process code, but I
have to say that I'm extremely surprised that this bug didn't attract much
attention, it actually renders any USB Ethernet device unusable on FreeBSD...

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to