From f709eddf9f659d547c5b75b659863bf98e422ba8 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Tue, 24 Oct 2000 22:38:54 +0000 Subject: Convert the USB ethernet drivers to use mutexes. Also convert usb_ethersubr.c. This module maintains two queues for packets which are each protected with one mutex. These are all the changes I can do for now. Removing the USBD_NO_TSLEEP flag doesn't work yet: when I tried it, the system would usually freeze up after a NIC had been operating for a while. The usb_ethersubr module itself ought to go away; this is the next thing I need to test. --- sys/dev/usb/usb_ethersubr.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'sys/dev/usb/usb_ethersubr.c') diff --git a/sys/dev/usb/usb_ethersubr.c b/sys/dev/usb/usb_ethersubr.c index da2328c37186..c02ed7dd0cb7 100644 --- a/sys/dev/usb/usb_ethersubr.c +++ b/sys/dev/usb/usb_ethersubr.c @@ -73,7 +73,10 @@ Static const char rcsid[] = #endif Static struct ifqueue usbq_rx; +Static struct mtx usbq_rx_mtx; Static struct ifqueue usbq_tx; +Static struct mtx usbq_tx_mtx; +Static int mtx_inited = 0; Static void usbintr __P((void)); @@ -83,13 +86,12 @@ Static void usbintr() struct mbuf *m; struct usb_qdat *q; struct ifnet *ifp; - int s; - - s = splimp(); /* Check the RX queue */ while(1) { + mtx_enter(&usbq_rx_mtx, MTX_DEF); IF_DEQUEUE(&usbq_rx, m); + mtx_exit(&usbq_rx_mtx, MTX_DEF); if (m == NULL) break; eh = mtod(m, struct ether_header *); @@ -107,7 +109,9 @@ Static void usbintr() /* Check the TX queue */ while(1) { + mtx_enter(&usbq_tx_mtx, MTX_DEF); IF_DEQUEUE(&usbq_tx, m); + mtx_exit(&usbq_tx_mtx, MTX_DEF); if (m == NULL) break; ifp = m->m_pkthdr.rcvif; @@ -116,14 +120,17 @@ Static void usbintr() (*ifp->if_start)(ifp); } - splx(s); - return; } void usb_register_netisr() { + if (mtx_inited) + return; register_netisr(NETISR_USB, usbintr); + mtx_init(&usbq_tx_mtx, "usbq_tx_mtx", MTX_DEF); + mtx_init(&usbq_rx_mtx, "usbq_rx_mtx", MTX_DEF); + mtx_inited++; return; } @@ -134,21 +141,21 @@ void usb_register_netisr() void usb_ether_input(m) struct mbuf *m; { - int s; - s = splimp(); + mtx_enter(&usbq_rx_mtx, MTX_DEF); IF_ENQUEUE(&usbq_rx, m); + mtx_exit(&usbq_rx_mtx, MTX_DEF); schednetisr(NETISR_USB); - splx(s); + return; } void usb_tx_done(m) struct mbuf *m; { - int s; - s = splimp(); + mtx_enter(&usbq_tx_mtx, MTX_DEF); IF_ENQUEUE(&usbq_tx, m); + mtx_exit(&usbq_tx_mtx, MTX_DEF); schednetisr(NETISR_USB); - splx(s); + return; } -- cgit v1.2.3