| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: usbnet.c,v 1.56 2022/03/03 05:48:22 riastradh Exp $ */ | | 1 | /* $NetBSD: usbnet.c,v 1.57 2022/03/03 05:48:30 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2019 Matthew R. Green | | 4 | * Copyright (c) 2019 Matthew R. Green |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * Common code shared between USB network drivers. | | 30 | * Common code shared between USB network drivers. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.56 2022/03/03 05:48:22 riastradh Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.57 2022/03/03 05:48:30 riastradh Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/kmem.h> | | 38 | #include <sys/kmem.h> |
39 | #include <sys/module.h> | | 39 | #include <sys/module.h> |
40 | #include <sys/atomic.h> | | 40 | #include <sys/atomic.h> |
41 | | | 41 | |
42 | #include <dev/usb/usbnet.h> | | 42 | #include <dev/usb/usbnet.h> |
43 | #include <dev/usb/usbhist.h> | | 43 | #include <dev/usb/usbhist.h> |
44 | | | 44 | |
45 | struct usbnet_cdata { | | 45 | struct usbnet_cdata { |
46 | struct usbnet_chain *uncd_tx_chain; | | 46 | struct usbnet_chain *uncd_tx_chain; |
47 | struct usbnet_chain *uncd_rx_chain; | | 47 | struct usbnet_chain *uncd_rx_chain; |
| @@ -973,26 +973,29 @@ usbnet_mii_statchg(struct ifnet *ifp) | | | @@ -973,26 +973,29 @@ usbnet_mii_statchg(struct ifnet *ifp) |
973 | } | | 973 | } |
974 | | | 974 | |
975 | static int | | 975 | static int |
976 | usbnet_media_upd(struct ifnet *ifp) | | 976 | usbnet_media_upd(struct ifnet *ifp) |
977 | { | | 977 | { |
978 | USBNETHIST_FUNC(); USBNETHIST_CALLED(); | | 978 | USBNETHIST_FUNC(); USBNETHIST_CALLED(); |
979 | struct usbnet * const un = ifp->if_softc; | | 979 | struct usbnet * const un = ifp->if_softc; |
980 | struct usbnet_private * const unp = un->un_pri; | | 980 | struct usbnet_private * const unp = un->un_pri; |
981 | struct mii_data * const mii = usbnet_mii(un); | | 981 | struct mii_data * const mii = usbnet_mii(un); |
982 | | | 982 | |
983 | /* ifmedia layer ensures core_lock is held. */ | | 983 | /* ifmedia layer ensures core_lock is held. */ |
984 | usbnet_isowned_core(un); | | 984 | usbnet_isowned_core(un); |
985 | | | 985 | |
| | | 986 | /* ifmedia changes only with IFNET_LOCK held. */ |
| | | 987 | KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname); |
| | | 988 | |
986 | if (unp->unp_dying) | | 989 | if (unp->unp_dying) |
987 | return EIO; | | 990 | return EIO; |
988 | | | 991 | |
989 | unp->unp_link = false; | | 992 | unp->unp_link = false; |
990 | | | 993 | |
991 | if (mii->mii_instance) { | | 994 | if (mii->mii_instance) { |
992 | struct mii_softc *miisc; | | 995 | struct mii_softc *miisc; |
993 | | | 996 | |
994 | LIST_FOREACH(miisc, &mii->mii_phys, mii_list) | | 997 | LIST_FOREACH(miisc, &mii->mii_phys, mii_list) |
995 | mii_phy_reset(miisc); | | 998 | mii_phy_reset(miisc); |
996 | } | | 999 | } |
997 | | | 1000 | |
998 | return ether_mediachange(ifp); | | 1001 | return ether_mediachange(ifp); |