Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb usbnet drivers: Omit needless usbnet core lock a...



details:   https://anonhg.NetBSD.org/src/rev/77cdd092990d
branches:  trunk
changeset: 362540:77cdd092990d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:54:37 2022 +0000

description:
usbnet drivers: Omit needless usbnet core lock and assertions.

During attach, the caller has exclusive access to the usbnet until
usbnet_attach_ifp.  At other times, register access is serialized
either by the usbnet multicast lock or by IFNET_LOCK.

diffstat:

 sys/dev/usb/if_aue.c  |  10 ++--------
 sys/dev/usb/if_axe.c  |  13 ++-----------
 sys/dev/usb/if_axen.c |  19 ++-----------------
 sys/dev/usb/if_cue.c  |   8 ++------
 sys/dev/usb/if_mue.c  |   8 ++------
 sys/dev/usb/if_smsc.c |  15 ++-------------
 sys/dev/usb/if_udav.c |   9 ++-------
 sys/dev/usb/if_ure.c  |  10 ++--------
 sys/dev/usb/if_url.c  |   9 ++-------
 9 files changed, 18 insertions(+), 83 deletions(-)

diffs (truncated from 490 to 300 lines):

diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_aue.c      Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.185 2022/03/03 05:54:21 riastradh Exp $   */
+/*     $NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.185 2022/03/03 05:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -432,8 +432,6 @@
        int                     off = 0;
        int                     word;
 
-       usbnet_isowned_core(un);
-
        AUEHIST_FUNC();
        AUEHIST_CALLARGS("aue%jd: enter",
            device_unit(un->un_dev), 0, 0, 0);
@@ -851,14 +849,10 @@
        /* First level attach. */
        usbnet_attach(un, "auedet");
 
-       usbnet_lock_core(un);
-
        /* Reset the adapter and get station address from the EEPROM.  */
        aue_reset(sc);
        aue_read_mac(un);
 
-       usbnet_unlock_core(un);
-
        usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
            0, &unm);
 }
diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_axe.c      Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.144 2022/03/03 05:54:21 riastradh Exp $   */
+/*     $NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $   */
 /*     $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.144 2022/03/03 05:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -513,8 +513,6 @@
 axe_reset(struct usbnet *un)
 {
 
-       usbnet_isowned_core(un);
-
        if (usbnet_isdying(un))
                return;
 
@@ -930,10 +928,8 @@
        usbnet_attach(un, "axedet");
 
        /* We need the PHYID for init dance in some cases */
-       usbnet_lock_core(un);
        if (axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, &sc->axe_phyaddrs)) {
                aprint_error_dev(self, "failed to read phyaddrs\n");
-               usbnet_unlock_core(un);
                return;
        }
 
@@ -963,13 +959,10 @@
        } else {
                if (axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->axe_ipgs)) {
                        aprint_error_dev(self, "failed to read ipg\n");
-                       usbnet_unlock_core(un);
                        return;
                }
        }
 
-       usbnet_unlock_core(un);
-
        if (!AXE_IS_172(un))
                usbnet_ec(un)->ec_capabilities = ETHERCAP_VLAN_MTU;
        if (un->un_flags & AX772B) {
@@ -1218,8 +1211,6 @@
        struct axe_softc * const sc = usbnet_softc(un);
        int rxmode;
 
-       usbnet_isowned_core(un);
-
        if (usbnet_isdying(un))
                return EIO;
 
diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_axen.c     Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.88 2022/03/03 05:54:21 riastradh Exp $   */
+/*     $NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $   */
 /*     $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.88 2022/03/03 05:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -295,7 +295,6 @@
 static void
 axen_reset(struct usbnet *un)
 {
-       usbnet_isowned_core(un);
        if (usbnet_isdying(un))
                return;
        /* XXX What to reset? */
@@ -367,8 +366,6 @@
        uint16_t wval;
        uint8_t val;
 
-       usbnet_lock_core(un);
-
        /* XXX: ? */
        axen_cmd(un, AXEN_CMD_MAC_READ, 1, AXEN_UNK_05, &val);
        DPRINTFN(5, ("AXEN_CMD_MAC_READ(0x05): 0x%02x\n", val));
@@ -451,7 +448,6 @@
        default:
                aprint_error_dev(un->un_dev, "unknown uplink bus:0x%02x\n",
                    val);
-               usbnet_unlock_core(un);
                return;
        }
        axen_cmd(un, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL, &qctrl);
@@ -509,8 +505,6 @@
        axen_uno_mii_write_reg(un, un->un_phyno, 0x01, wval | 0x0080);
        axen_uno_mii_write_reg(un, un->un_phyno, 0x1F, 0x0000);
 #endif
-
-       usbnet_unlock_core(un);
 }
 
 static void
@@ -554,8 +548,6 @@
 {
        struct usbnet * const un = ifp->if_softc;
 
-       usbnet_lock_core(un);
-
        switch (cmd) {
        case SIOCSIFCAP:
                axen_setoe_locked(un);
@@ -564,8 +556,6 @@
                break;
        }
 
-       usbnet_unlock_core(un);
-
        return 0;
 }
 
@@ -666,13 +656,10 @@
        DPRINTF(("%s: phyno %d\n", device_xname(self), un->un_phyno));
 
        /* Get station address.  */
-       usbnet_lock_core(un);
        if (axen_get_eaddr(un, &un->un_eaddr)) {
-               usbnet_unlock_core(un);
                printf("EEPROM checksum error\n");
                return;
        }
-       usbnet_unlock_core(un);
 
        axen_ax88179_init(un);
 
@@ -889,8 +876,6 @@
        uint16_t wval;
        uint8_t bval;
 
-       usbnet_isowned_core(un);
-
        if (usbnet_isdying(un))
                return EIO;
 
diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_cue.c      Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.101 2022/03/03 05:53:33 riastradh Exp $   */
+/*     $NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.101 2022/03/03 05:53:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -545,8 +545,6 @@
 {
        struct ifnet            *ifp = usbnet_ifp(un);
 
-       usbnet_lock_core(un);
-
        net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
        if (cue_csr_read_2(un, CUE_RX_FRAMEERR))
                if_statinc_ref(nsr, if_ierrors);
@@ -558,8 +556,6 @@
        if_statadd_ref(nsr, if_collisions,
            cue_csr_read_2(un, CUE_TX_EXCESSCOLL));
        IF_STAT_PUTREF(ifp);
-
-       usbnet_unlock_core(un);
 }
 
 static void
diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c      Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_mue.c      Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mue.c,v 1.76 2022/03/03 05:54:21 riastradh Exp $    */
+/*     $NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $    */
 /*     $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $  */
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Microchip LAN7500/LAN7800 chipsets. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.76 2022/03/03 05:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1261,8 +1261,6 @@
 {
        struct usbnet * const un = ifp->if_softc;
 
-       usbnet_lock_core(un);
-
        switch (cmd) {
        case SIOCSIFCAP:
                mue_sethwcsum_locked(un);
@@ -1274,8 +1272,6 @@
                break;
        }
 
-       usbnet_unlock_core(un);
-
        return 0;
 }
 
diff -r 9e648b25e85e -r 77cdd092990d sys/dev/usb/if_smsc.c
--- a/sys/dev/usb/if_smsc.c     Thu Mar 03 05:54:28 2022 +0000
+++ b/sys/dev/usb/if_smsc.c     Thu Mar 03 05:54:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smsc.c,v 1.86 2022/03/03 05:54:21 riastradh Exp $   */
+/*     $NetBSD: if_smsc.c,v 1.87 2022/03/03 05:54:37 riastradh Exp $   */
 
 /*     $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.86 2022/03/03 05:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.87 2022/03/03 05:54:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -539,7 +539,6 @@
 {
        struct usbnet * const un = &sc->smsc_un;
 
-       usbnet_isowned_core(un);
        if (usbnet_isdying(un))
                return;
 
@@ -556,8 +555,6 @@
        struct usbnet * const un = ifp->if_softc;
        struct smsc_softc * const sc = usbnet_softc(un);
 
-       usbnet_isowned_core(un);
-



Home | Main Index | Thread Index | Old Index