usb ethernet tick task will check the link status, also
SIOCGIFMEDIA/SIOCSIFMEDIA will check the link status. mutex is shared
between usb_ethernet code, miibus, usb_process, and chip driver (ex.
if_ure).
The problem is that usb_request.c:usbd_do_request_flags unconditionally
releases the mutex. So if we have tick code running, ioctl waiting to
acquire the mutex, the release of the mutex by usbd_do_request_flags
causes the ioctl code to run, racing with the tick code, causing
linkup/down (see bsc#252165).
To avoid that, we stop the tick watchog on SIOCGIFMEDIA/SIOCSIFMEDIA
ioctl if we are the only pending one, then we restore it back when
no more ioctl are left, actually there is no point to run the tick
watchdog code if we are going to check the link status in the ioctl code
anyway. In addition we use ioctl_cv condition variable
to serialize ioctl to avoid two ioctl's racing.
Unlike https://reviews.freebsd.org/D55682 (see also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252165#c62) where the proposed solution works only for if_ure, this solves the issue at the usb_ethernet code level, avoid touching various other chip drivers if_muge, if_axge, if_rue, etc...)