Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

HEADS UP: Ethernet / Wifi driver locking changes

Hey folks --

I've just checked in a large diff that implements an MP-safe locking protocol for the ifmedia / mii layers used by many Ethernet and Wifi drivers.  I've tested this fairly extensively, and have gotten some testing help from others as well.  But I can't cover everything, so if you notice any crashes or hangs or whatever that seem like they could be related to this, file a bug report using send-pr(1) and ping me via email.


-- thorpej

> Begin forwarded message:
> From: Jason R Thorpe <>
> Subject: CVS commit: src/sys
> Date: March 15, 2020 at 4:04:52 PM PDT
> To:
> Reply-To:
> Module Name:	src
> Committed By:	thorpej
> Date:		Sun Mar 15 23:04:51 UTC 2020
> Modified 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
> To generate a diff of this commit:
> cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/gxlphy.c
> cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/pci/if_vmx.c
> cvs rdiff -u -r1.29 -r1.30 src/sys/dev/mii/acphy.c src/sys/dev/mii/atphy.c
> cvs rdiff -u -r1.25 -r1.26 src/sys/dev/mii/amhphy.c src/sys/dev/mii/pnaphy.c
> cvs rdiff -u -r1.36 -r1.37 src/sys/dev/mii/bmtphy.c src/sys/dev/mii/gphyter.c
> cvs rdiff -u -r1.87 -r1.88 src/sys/dev/mii/brgphy.c
> cvs rdiff -u -r1.38 -r1.39 src/sys/dev/mii/ciphy.c src/sys/dev/mii/rlphy.c
> cvs rdiff -u -r1.46 -r1.47 src/sys/dev/mii/dmphy.c
> cvs rdiff -u -r1.8 -r1.9 src/sys/dev/mii/etphy.c
> cvs rdiff -u -r1.57 -r1.58 src/sys/dev/mii/exphy.c
> cvs rdiff -u -r1.30 -r1.31 src/sys/dev/mii/gentbi.c
> cvs rdiff -u -r1.31 -r1.32 src/sys/dev/mii/glxtphy.c
> cvs rdiff -u -r1.55 -r1.56 src/sys/dev/mii/icsphy.c src/sys/dev/mii/sqphy.c
> cvs rdiff -u -r1.32 -r1.33 src/sys/dev/mii/igphy.c
> cvs rdiff -u -r1.16 -r1.17 src/sys/dev/mii/ihphy.c \
>    src/sys/dev/mii/ukphy_subr.c
> cvs rdiff -u -r1.18 -r1.19 src/sys/dev/mii/ikphy.c
> cvs rdiff -u -r1.59 -r1.60 src/sys/dev/mii/inphy.c
> cvs rdiff -u -r1.42 -r1.43 src/sys/dev/mii/iophy.c
> cvs rdiff -u -r1.9 -r1.10 src/sys/dev/mii/ipgphy.c
> cvs rdiff -u -r1.3 -r1.4 src/sys/dev/mii/jmphy.c
> cvs rdiff -u -r1.54 -r1.55 src/sys/dev/mii/lxtphy.c src/sys/dev/mii/mii.c \
>    src/sys/dev/mii/qsphy.c
> cvs rdiff -u -r1.64 -r1.65 src/sys/dev/mii/makphy.c
> cvs rdiff -u -r1.12 -r1.13 src/sys/dev/mii/micphy.c
> cvs rdiff -u -r1.2 -r1.3 src/sys/dev/mii/mii_ethersubr.c \
>    src/sys/dev/mii/smscphy.c
> cvs rdiff -u -r1.89 -r1.90 src/sys/dev/mii/mii_physubr.c
> cvs rdiff -u -r1.69 -r1.70 src/sys/dev/mii/miivar.h
> cvs rdiff -u -r1.14 -r1.15 src/sys/dev/mii/mvphy.c
> cvs rdiff -u -r1.65 -r1.66 src/sys/dev/mii/nsphy.c
> cvs rdiff -u -r1.44 -r1.45 src/sys/dev/mii/nsphyter.c src/sys/dev/mii/tqphy.c
> cvs rdiff -u -r1.6 -r1.7 src/sys/dev/mii/rdcphy.c
> cvs rdiff -u -r1.58 -r1.59 src/sys/dev/mii/rgephy.c
> cvs rdiff -u -r1.67 -r1.68 src/sys/dev/mii/tlphy.c
> cvs rdiff -u -r1.52 -r1.53 src/sys/dev/mii/ukphy.c
> cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/if_mcx.c
> cvs rdiff -u -r1.668 -r1.669 src/sys/dev/pci/if_wm.c
> cvs rdiff -u -r1.226 -r1.227 src/sys/dev/pci/ixgbe/ixgbe.c
> cvs rdiff -u -r1.146 -r1.147 src/sys/dev/pci/ixgbe/ixv.c
> cvs rdiff -u -r1.71 -r1.72 src/sys/dev/usb/if_atu.c
> cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/if_atureg.h \
>    src/sys/dev/usb/if_otusvar.h src/sys/dev/usb/if_rumvar.h \
>    src/sys/dev/usb/if_zydreg.h
> cvs rdiff -u -r1.167 -r1.168 src/sys/dev/usb/if_aue.c
> cvs rdiff -u -r1.129 -r1.130 src/sys/dev/usb/if_axe.c
> cvs rdiff -u -r1.72 -r1.73 src/sys/dev/usb/if_axen.c
> cvs rdiff -u -r1.69 -r1.70 src/sys/dev/usb/if_cdce.c
> cvs rdiff -u -r1.90 -r1.91 src/sys/dev/usb/if_cue.c
> cvs rdiff -u -r1.102 -r1.103 src/sys/dev/usb/if_kue.c
> cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/if_mos.c \
>    src/sys/dev/usb/if_urtwreg.h
> cvs rdiff -u -r1.58 -r1.59 src/sys/dev/usb/if_mue.c src/sys/dev/usb/if_zyd.c
> cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/if_otus.c
> cvs rdiff -u -r1.68 -r1.69 src/sys/dev/usb/if_rum.c
> cvs rdiff -u -r1.38 -r1.39 src/sys/dev/usb/if_run.c \
>    src/sys/dev/usb/if_urndis.c
> cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/if_runvar.h
> cvs rdiff -u -r1.67 -r1.68 src/sys/dev/usb/if_smsc.c
> cvs rdiff -u -r1.76 -r1.77 src/sys/dev/usb/if_udav.c
> cvs rdiff -u -r1.30 -r1.31 src/sys/dev/usb/if_upgt.c
> cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_upgtvar.h
> cvs rdiff -u -r1.70 -r1.71 src/sys/dev/usb/if_upl.c
> cvs rdiff -u -r1.64 -r1.65 src/sys/dev/usb/if_ural.c
> cvs rdiff -u -r1.14 -r1.15 src/sys/dev/usb/if_uralvar.h
> cvs rdiff -u -r1.37 -r1.38 src/sys/dev/usb/if_ure.c src/sys/dev/usb/usbnet.c
> cvs rdiff -u -r1.75 -r1.76 src/sys/dev/usb/if_url.c
> cvs rdiff -u -r1.23 -r1.24 src/sys/dev/usb/if_urtw.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/dev/usb/if_urtwn.c
> cvs rdiff -u -r1.15 -r1.16 src/sys/dev/usb/if_urtwnvar.h
> cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/usbnet.h
> cvs rdiff -u -r1.51 -r1.52 src/sys/net/if_media.c
> cvs rdiff -u -r1.70 -r1.71 src/sys/net/if_media.h
> cvs rdiff -u -r1.58 -r1.59 src/sys/net80211/ieee80211.c
> cvs rdiff -u -r1.22 -r1.23 src/sys/net80211/ieee80211_netbsd.h
> cvs rdiff -u -r1.33 -r1.34 src/sys/net80211/ieee80211_var.h
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.

Home | Main Index | Thread Index | Old Index