Module Name: src Committed By: thorpej Date: Sun Mar 15 23:04:51 UTC 2020Modified Files: src/sys/arch/arm/amlogic: gxlphy.c src/sys/arch/x86/pci: if_vmx.c src/sys/dev/mii: acphy.c amhphy.c atphy.c bmtphy.c brgphy.c ciphy.c dmphy.c etphy.c exphy.c gentbi.c glxtphy.c gphyter.c icsphy.c igphy.c ihphy.c ikphy.c inphy.c iophy.c ipgphy.c jmphy.c lxtphy.c makphy.c micphy.c mii.c mii_ethersubr.c mii_physubr.c miivar.h mvphy.c nsphy.c nsphyter.c pnaphy.c qsphy.c rdcphy.c rgephy.c rlphy.c smscphy.c sqphy.c tlphy.c tqphy.c ukphy.c ukphy_subr.c src/sys/dev/pci: if_mcx.c if_wm.c src/sys/dev/pci/ixgbe: ixgbe.c ixv.c src/sys/dev/usb: if_atu.c if_atureg.h if_aue.c if_axe.c if_axen.c if_cdce.c if_cue.c if_kue.c if_mos.c if_mue.c if_otus.c if_otusvar.h if_rum.c if_rumvar.h if_run.c if_runvar.h if_smsc.c if_udav.c if_upgt.c if_upgtvar.h if_upl.c if_ural.c if_uralvar.h if_ure.c if_url.c if_urndis.c if_urtw.c if_urtwn.c if_urtwnvar.h if_urtwreg.h if_zyd.c if_zydreg.h usbnet.c usbnet.h src/sys/net: if_media.c if_media.h src/sys/net80211: ieee80211.c ieee80211_netbsd.h ieee80211_var.h Log Message: Define and implement a locking protocol for the ifmedia / mii layers: - MP-safe drivers provide a mutex to ifmedia that is used to serialize access to media-related structures / hardware regsiters. Converted drivers use the new ifmedia_init_with_lock() function for this. The new name is provided to ease the transition. - Un-converted drivers continue to call ifmedia_init(), which will supply a compatibility lock to be used instead. Several media-related entry points must be aware of this compatibility lock, and are able to acquire it recursively a limited number of times, if needed. This is a SPIN mutex with priority IPL_NET. - This same lock is used to serialize access to PHY registers and other MII-related data structures. The PHY drivers are modified to acquire and release the lock, as needed, and assert the lock is held as a diagnostic aid. The "usbnet" framework has had an overhaul of its internal locking protocols to fit in with the media / mii changes, and the drivers adapted. USB wifi drivers have been changed to provide their own adaptive mutex to the ifmedia later via a new ieee80211_media_init_with_lock() function. This is required because the USB drivers need an adaptive mutex. Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv. mcx also now calls ifmedia_init_with_lock() because it needs to also use an adaptive mutex. The mcx driver still needs to be fully converted to NET_MPSAFE.
Since this change if_udav.c doesn't work. Simply plugging a USB-to-ethernet device triggers a page fault on mutex_enter in udav_attach. Quickly looking at the code: 240 usbnet_lock_core(un); 241 usbnet_busy(un); 242 243 // /* reset the adapter */ 244 // udav_reset(un); 245 246 usbnet_attach(un, "udavdet"); usbnet_lock_core uses un_pri, but un_pri is initialized only in usbnet_attach.
