Move from workqueue to an explicit kthread for setting the multicast
filter, as suggested by cube@. Actual code review by cube@. This way, a backport of the fix to netbsd-4 is possible.
This commit is contained in:
parent
76e0b9a57a
commit
257a88e757
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: if_aue.c,v 1.107 2008/01/12 22:32:51 cube Exp $ */
|
/* $NetBSD: if_aue.c,v 1.108 2008/01/16 12:33:54 is Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 1998, 1999, 2000
|
* Copyright (c) 1997, 1998, 1999, 2000
|
||||||
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
|
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
|
||||||
@ -77,7 +77,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.107 2008/01/12 22:32:51 cube Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.108 2008/01/16 12:33:54 is Exp $");
|
||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
#include "opt_inet.h"
|
#include "opt_inet.h"
|
||||||
@ -141,7 +141,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.107 2008/01/12 22:32:51 cube Exp $");
|
|||||||
#include <dev/usb/usbdevs.h>
|
#include <dev/usb/usbdevs.h>
|
||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
#include <sys/workqueue.h>
|
#include <sys/condvar.h>
|
||||||
|
#include <sys/kthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <dev/usb/if_auereg.h>
|
#include <dev/usb/if_auereg.h>
|
||||||
@ -234,7 +235,7 @@ Static const struct aue_type aue_devs[] = {
|
|||||||
USB_DECLARE_DRIVER(aue);
|
USB_DECLARE_DRIVER(aue);
|
||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
Static void aue_multiwork(struct work *wkp, void *arg);
|
Static void aue_multithread(void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Static void aue_reset_pegasus_II(struct aue_softc *sc);
|
Static void aue_reset_pegasus_II(struct aue_softc *sc);
|
||||||
@ -780,17 +781,21 @@ USB_ATTACH(aue)
|
|||||||
USB_ATTACH_ERROR_RETURN;
|
USB_ATTACH_ERROR_RETURN;
|
||||||
}
|
}
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
err = workqueue_create(&sc->wqp, USBDEVNAME(sc->aue_dev),
|
sc->aue_closing = 0;
|
||||||
aue_multiwork, sc, 0, IPL_NET, 0);
|
|
||||||
|
mutex_init(&sc->aue_mcmtx, MUTEX_DRIVER, IPL_NET);
|
||||||
|
cv_init(&sc->aue_domc, "auemc");
|
||||||
|
cv_init(&sc->aue_closemc, "auemccl");
|
||||||
|
|
||||||
|
err = kthread_create(PRI_NONE, 0, NULL,
|
||||||
|
aue_multithread, sc, &sc->aue_thread,
|
||||||
|
"%s-mc", USBDEVNAME(sc->aue_dev));
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("%s: creating multicast configuration work queue\n",
|
printf("%s: creating multicast configuration thread\n",
|
||||||
USBDEVNAME(sc->aue_dev));
|
USBDEVNAME(sc->aue_dev));
|
||||||
USB_ATTACH_ERROR_RETURN;
|
USB_ATTACH_ERROR_RETURN;
|
||||||
}
|
}
|
||||||
sc->wksem = 0;
|
|
||||||
mutex_init(&sc->wkmtx, MUTEX_DRIVER, IPL_NET);
|
|
||||||
cv_init(&sc->wkdone, "auewk");
|
|
||||||
#endif
|
#endif
|
||||||
sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags;
|
sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags;
|
||||||
|
|
||||||
@ -906,15 +911,6 @@ USB_DETACH(aue)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_enter(&sc->wkmtx);
|
|
||||||
while (sc->wksem != 0)
|
|
||||||
cv_wait(&sc->wkdone, &sc->wkmtx);
|
|
||||||
sc->wksem = 1;
|
|
||||||
mutex_exit(&sc->wkmtx);
|
|
||||||
|
|
||||||
/* It is now safe to terminate the worker */
|
|
||||||
workqueue_destroy(sc->wqp);
|
|
||||||
|
|
||||||
usb_uncallout(sc->aue_stat_ch, aue_tick, sc);
|
usb_uncallout(sc->aue_stat_ch, aue_tick, sc);
|
||||||
/*
|
/*
|
||||||
* Remove any pending tasks. They cannot be executing because they run
|
* Remove any pending tasks. They cannot be executing because they run
|
||||||
@ -923,6 +919,17 @@ USB_DETACH(aue)
|
|||||||
usb_rem_task(sc->aue_udev, &sc->aue_tick_task);
|
usb_rem_task(sc->aue_udev, &sc->aue_tick_task);
|
||||||
usb_rem_task(sc->aue_udev, &sc->aue_stop_task);
|
usb_rem_task(sc->aue_udev, &sc->aue_stop_task);
|
||||||
|
|
||||||
|
sc->aue_closing = 1;
|
||||||
|
cv_signal(&sc->aue_domc);
|
||||||
|
|
||||||
|
mutex_enter(&sc->aue_mcmtx);
|
||||||
|
cv_wait(&sc->aue_closemc,&sc->aue_mcmtx);
|
||||||
|
mutex_exit(&sc->aue_mcmtx);
|
||||||
|
|
||||||
|
mutex_destroy(&sc->aue_mcmtx);
|
||||||
|
cv_destroy(&sc->aue_domc);
|
||||||
|
cv_destroy(&sc->aue_closemc);
|
||||||
|
|
||||||
s = splusb();
|
s = splusb();
|
||||||
|
|
||||||
if (ifp->if_flags & IFF_RUNNING)
|
if (ifp->if_flags & IFF_RUNNING)
|
||||||
@ -959,8 +966,9 @@ USB_DETACH(aue)
|
|||||||
USBDEV(sc->aue_dev));
|
USBDEV(sc->aue_dev));
|
||||||
|
|
||||||
mutex_destroy(&sc->aue_mii_lock);
|
mutex_destroy(&sc->aue_mii_lock);
|
||||||
|
#if 0
|
||||||
mutex_destroy(&sc->wkmtx);
|
mutex_destroy(&sc->wkmtx);
|
||||||
|
#endif
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1650,10 +1658,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, void *data)
|
|||||||
if ((error = ether_ioctl(ifp, command, data)) == ENETRESET) {
|
if ((error = ether_ioctl(ifp, command, data)) == ENETRESET) {
|
||||||
if (ifp->if_flags & IFF_RUNNING) {
|
if (ifp->if_flags & IFF_RUNNING) {
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
mutex_enter(&sc->wkmtx);
|
cv_signal(&sc->aue_domc);
|
||||||
if (sc->wksem == 0)
|
|
||||||
workqueue_enqueue(sc->wqp,&sc->wk, NULL);
|
|
||||||
mutex_exit(&sc->wkmtx);
|
|
||||||
#else
|
#else
|
||||||
aue_init(sc);
|
aue_init(sc);
|
||||||
aue_setmulti(sc);
|
aue_setmulti(sc);
|
||||||
@ -1795,18 +1800,29 @@ aue_stop(struct aue_softc *sc)
|
|||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
Static void
|
Static void
|
||||||
aue_multiwork(struct work *wkp, void *arg) {
|
aue_multithread(void *arg) {
|
||||||
struct aue_softc *sc;
|
struct aue_softc *sc;
|
||||||
|
int s;
|
||||||
|
|
||||||
sc = (struct aue_softc *)arg;
|
sc = (struct aue_softc *)arg;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
mutex_enter(&sc->aue_mcmtx);
|
||||||
|
cv_wait(&sc->aue_domc,&sc->aue_mcmtx);
|
||||||
|
mutex_exit(&sc->aue_mcmtx);
|
||||||
|
|
||||||
|
if (sc->aue_closing)
|
||||||
|
break;
|
||||||
|
|
||||||
|
s = splnet();
|
||||||
aue_init(sc);
|
aue_init(sc);
|
||||||
/* XXX called by aue_init, but rc ifconfig hangs without it: */
|
/* XXX called by aue_init, but rc ifconfig hangs without it: */
|
||||||
aue_setmulti(sc);
|
aue_setmulti(sc);
|
||||||
|
splx(s);
|
||||||
|
}
|
||||||
|
|
||||||
mutex_enter(&sc->wkmtx);
|
cv_signal(&sc->aue_closemc);
|
||||||
sc->wksem = 0;
|
|
||||||
cv_signal(&sc->wkdone);
|
kthread_exit(0);
|
||||||
mutex_exit(&sc->wkmtx);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: if_auereg.h,v 1.19 2008/01/12 22:32:51 cube Exp $ */
|
/* $NetBSD: if_auereg.h,v 1.20 2008/01/16 12:33:54 is Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 1998, 1999
|
* Copyright (c) 1997, 1998, 1999
|
||||||
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
|
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
|
||||||
@ -237,11 +237,11 @@ struct aue_softc {
|
|||||||
#if NRND > 0
|
#if NRND > 0
|
||||||
rndsource_element_t rnd_source;
|
rndsource_element_t rnd_source;
|
||||||
#endif
|
#endif
|
||||||
struct workqueue *wqp;
|
struct lwp *aue_thread;
|
||||||
struct work wk;
|
int aue_closing;
|
||||||
u_int wksem;
|
kcondvar_t aue_domc;
|
||||||
kcondvar_t wkdone;
|
kcondvar_t aue_closemc;
|
||||||
kmutex_t wkmtx;
|
kmutex_t aue_mcmtx;
|
||||||
#define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
|
#define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
|
||||||
#define GET_MII(sc) (&(sc)->aue_mii)
|
#define GET_MII(sc) (&(sc)->aue_mii)
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
|
Loading…
Reference in New Issue
Block a user