Module Name: src Committed By: riastradh Date: Thu Mar 3 05:52:20 UTC 2022
Modified Files: src/sys/dev/usb: if_axe.c if_cdce.c usbnet.c usbnet.h Log Message: usbnet: Make the tx/rx locks private to usbnet.c. Suffice it for the drivers to know that uno_tx_prepare and uno_rx_loop have exclusive access to the chain, and, for tx, exclusive access to the mbuf. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/dev/usb/if_axe.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/usb/if_cdce.c cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/usbnet.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/usbnet.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/if_axe.c diff -u src/sys/dev/usb/if_axe.c:1.137 src/sys/dev/usb/if_axe.c:1.138 --- src/sys/dev/usb/if_axe.c:1.137 Thu Mar 3 05:51:44 2022 +++ src/sys/dev/usb/if_axe.c Thu Mar 3 05:52:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_axe.c,v 1.137 2022/03/03 05:51:44 riastradh Exp $ */ +/* $NetBSD: if_axe.c,v 1.138 2022/03/03 05:52:20 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.137 2022/03/03 05:51:44 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.138 2022/03/03 05:52:20 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1136,8 +1136,6 @@ axe_uno_tx_prepare(struct usbnet *un, st size_t hdr_len = 0, tlr_len = 0; int length, boundary; - usbnet_isowned_tx(un); - if (!AXE_IS_172(un)) { /* * Copy the mbuf data into a contiguous buffer, leaving two Index: src/sys/dev/usb/if_cdce.c diff -u src/sys/dev/usb/if_cdce.c:1.73 src/sys/dev/usb/if_cdce.c:1.74 --- src/sys/dev/usb/if_cdce.c:1.73 Thu Mar 3 05:50:22 2022 +++ src/sys/dev/usb/if_cdce.c Thu Mar 3 05:52:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 riastradh Exp $ */ +/* $NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wp...@windriver.com> @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $"); #include <sys/param.h> @@ -277,8 +277,6 @@ cdce_uno_rx_loop(struct usbnet * un, str { struct ifnet *ifp = usbnet_ifp(un); - usbnet_isowned_rx(un); - /* Strip off CRC added by Zaurus, if present */ if (un->un_flags & CDCE_ZAURUS && total_len > 4) total_len -= 4; Index: src/sys/dev/usb/usbnet.c diff -u src/sys/dev/usb/usbnet.c:1.78 src/sys/dev/usb/usbnet.c:1.79 --- src/sys/dev/usb/usbnet.c:1.78 Thu Mar 3 05:52:11 2022 +++ src/sys/dev/usb/usbnet.c Thu Mar 3 05:52:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usbnet.c,v 1.78 2022/03/03 05:52:11 riastradh Exp $ */ +/* $NetBSD: usbnet.c,v 1.79 2022/03/03 05:52:20 riastradh Exp $ */ /* * Copyright (c) 2019 Matthew R. Green @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.78 2022/03/03 05:52:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.79 2022/03/03 05:52:20 riastradh Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -96,6 +96,9 @@ struct usbnet_private { volatile unsigned usbnet_number; +static void usbnet_isowned_rx(struct usbnet *); +static void usbnet_isowned_tx(struct usbnet *); + static int usbnet_modcmd(modcmd_t, void *); #ifdef USB_DEBUG @@ -1323,46 +1326,22 @@ usbnet_unlock_core(struct usbnet *un) mutex_exit(&un->un_pri->unp_core_lock); } -kmutex_t * +kmutex_t* usbnet_mutex_core(struct usbnet *un) { return &un->un_pri->unp_core_lock; } -void -usbnet_lock_rx(struct usbnet *un) -{ - mutex_enter(&un->un_pri->unp_rxlock); -} - -void -usbnet_unlock_rx(struct usbnet *un) -{ - mutex_exit(&un->un_pri->unp_rxlock); -} - -kmutex_t * -usbnet_mutex_rx(struct usbnet *un) -{ - return &un->un_pri->unp_rxlock; -} - -void -usbnet_lock_tx(struct usbnet *un) -{ - mutex_enter(&un->un_pri->unp_txlock); -} - -void -usbnet_unlock_tx(struct usbnet *un) +static void +usbnet_isowned_rx(struct usbnet *un) { - mutex_exit(&un->un_pri->unp_txlock); + KASSERT(mutex_owned(&un->un_pri->unp_rxlock)); } -kmutex_t * -usbnet_mutex_tx(struct usbnet *un) +static void +usbnet_isowned_tx(struct usbnet *un) { - return &un->un_pri->unp_txlock; + KASSERT(mutex_owned(&un->un_pri->unp_txlock)); } /* Autoconf management. */ Index: src/sys/dev/usb/usbnet.h diff -u src/sys/dev/usb/usbnet.h:1.25 src/sys/dev/usb/usbnet.h:1.26 --- src/sys/dev/usb/usbnet.h:1.25 Thu Mar 3 05:52:11 2022 +++ src/sys/dev/usb/usbnet.h Thu Mar 3 05:52:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usbnet.h,v 1.25 2022/03/03 05:52:11 riastradh Exp $ */ +/* $NetBSD: usbnet.h,v 1.26 2022/03/03 05:52:20 riastradh Exp $ */ /* * Copyright (c) 2019 Matthew R. Green @@ -311,24 +311,6 @@ usbnet_isowned_core(struct usbnet *un) KASSERT(mutex_owned(usbnet_mutex_core(un))); } -void usbnet_lock_rx(struct usbnet *); -void usbnet_unlock_rx(struct usbnet *); -kmutex_t *usbnet_mutex_rx(struct usbnet *); -static __inline__ void -usbnet_isowned_rx(struct usbnet *un) -{ - KASSERT(mutex_owned(usbnet_mutex_rx(un))); -} - -void usbnet_lock_tx(struct usbnet *); -void usbnet_unlock_tx(struct usbnet *); -kmutex_t *usbnet_mutex_tx(struct usbnet *); -static __inline__ void -usbnet_isowned_tx(struct usbnet *un) -{ - KASSERT(mutex_owned(usbnet_mutex_tx(un))); -} - /* * Endpoint / rx/tx chain management: *