From owner-freebsd-usb@FreeBSD.ORG Sun Apr 29 13:25:10 2007 Return-Path: X-Original-To: freebsd-usb@FreeBSD.org Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D720C16A406 for ; Sun, 29 Apr 2007 13:25:10 +0000 (UTC) (envelope-from valera@chikalov.dp.ua) Received: from halik.com.ua (halik.com.ua [193.178.146.121]) by mx1.freebsd.org (Postfix) with ESMTP id 266D313C45D for ; Sun, 29 Apr 2007 13:25:09 +0000 (UTC) (envelope-from valera@chikalov.dp.ua) Received: from [192.168.1.103] (unknown [213.227.219.58]) by halik.com.ua (Postfix) with ESMTP id F14C65C06D; Sun, 29 Apr 2007 16:02:16 +0300 (EEST) Message-ID: <46349750.7060206@chikalov.dp.ua> Date: Sun, 29 Apr 2007 16:02:08 +0300 From: "Valery V.Chikalov" User-Agent: Thunderbird 1.5.0.9 (X11/20070315) MIME-Version: 1.0 To: Kevin Lo , freebsd-usb@FreeBSD.org References: <200704272330.l3RNU94X078095@freefall.freebsd.org> <1177767702.5804.7.camel@monet> In-Reply-To: <1177767702.5804.7.camel@monet> Content-Type: multipart/mixed; boundary="------------050105000400040604070109" Cc: Subject: Re: usb/107642: [patch]Ralink Technology RT2501USB/RT2601USB chipset driver X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2007 13:25:10 -0000 This is a multi-part message in MIME format. --------------050105000400040604070109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Kevin Lo wrote: > Valery V.Chikalov wrote: >> The following reply was made to PR usb/107642; it has been noted by GNATS. >> >> From: "Valery V.Chikalov" >> To: bug-followup@FreeBSD.org, valera@chikalov.dp.ua >> Cc: >> Subject: Re: usb/107642: [patch]Ralink Technology RT2501USB/RT2601USB chipset >> driver >> Date: Sun, 22 Apr 2007 11:32:18 +0300 >> >> This is a multi-part message in MIME format. >> --------------030900090303000507070905 >> Content-Type: text/plain; charset=UTF-8 >> Content-Transfer-Encoding: 7bit >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> if_rum(4) for 7.0-CURRENT >> >> replaced amrr_* functions by "standard" ones already existed in >> net80211/ieee80211_amrr.c >> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.5 (MingW32) >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org >> >> iD8DBQFGKx14760S3kDvEC4RAn8PAKCn990QJE0wZRKcwdxAZ61MY0JRgACeI2W5 >> ZosSlh6pIqi7JdZ5Wi1BUYc= >> =LvWZ >> -----END PGP SIGNATURE----- > > Hi Valery, > > I guess you wasn't aware that I've already ported rum(4) to FreeBSD. > The patch is available at: http://people.freebsd.org/~kevlo/patch-rum > Maybe you can test my patch? Thanks. > > Kevin > > Hi, Kevin, Your driver not working for me. Fortunately, the errors that I see exactly the same which i fight when I made my driver. $ uname -a FreeBSD tiger.novakom.dp.ua 7.0-CURRENT FreeBSD 7.0-CURRENT #6: Sun Apr 29 13:58:48 EEST 2007 root@tiger.novakom.dp.ua:/usr/obj/usr/src/sys/TIGER64 amd64 $ sysctl kern.osreldate kern.osreldate: 700037 cvsup'ed 29.04.2007 kernel with: makeoptions DEBUG=-g options KDB options DDB options INVARIANTS options INVARIANT_SUPPORT options WITNESS At first, when I make kldload if_rum, I get kernel panic. But I cant get saved core, as ddb just hangs during "call doadump" So I add #define RUM_LOCK(sc) do { ((sc) = (sc)); mtx_lock(&Giant); } while (0) #define RUM_UNLOCK(sc) mtx_unlock(&Giant) in if_rumvar.h I spend a lot of time in attempts get rid of Giant ant always got only panics. After that I get hangs, which i resolved by modifying rum_ioctl: - RUM_LOCK(sc); - switch (cmd) { case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING){ + RUM_LOCK(sc); rum_update_promisc(sc); - else + RUM_UNLOCK(sc); + } else { + RUM_LOCK(sc); rum_init(sc); + RUM_UNLOCK(sc); + } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING){ + RUM_LOCK(sc); rum_stop(sc); + RUM_UNLOCK(sc); + } } break; default: @@ -1488,12 +1501,13 @@ if (error == ENETRESET) { if ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING) && - (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)) - rum_init(sc); + (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)){ + RUM_LOCK(sc); + rum_init(sc); + RUM_UNLOCK(sc); + } error = 0; } - - RUM_UNLOCK(sc); After that changes at first glance driver is working, but I getting the panic during "high load", for example trying to get by ftp relatively big file (about 200Mb) at this time I can even get the saved kernel coredump, so I can give your more information if you wish. And the next changes (I know it looks ugly), made the driver working. In function rum_start: + static int fbusy = 0; + + if (fbusy) return; + + fbusy = 1; for (;;) { IF_POLL(&ic->ic_mgtq, m0); @@ -1439,6 +1444,8 @@ sc->sc_tx_timer = 5; callout_reset(&sc->watchdog_ch, hz, rum_watchdog, sc); } + + fbusy = 0; I'm sure you can make the "right" patches which resolves this issues. Valery. --------------050105000400040604070109 Content-Type: text/plain; name="if_rum.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="if_rum.c.diff" --- if_rum.c.orig Sun Apr 29 15:32:28 2007 +++ if_rum.c Sun Apr 29 15:26:22 2007 @@ -1376,6 +1376,11 @@ struct ieee80211_node *ni; struct mbuf *m0; struct ether_header *eh; + static int fbusy = 0; + + if (fbusy) return; + + fbusy = 1; for (;;) { IF_POLL(&ic->ic_mgtq, m0); @@ -1439,6 +1444,8 @@ sc->sc_tx_timer = 5; callout_reset(&sc->watchdog_ch, hz, rum_watchdog, sc); } + + fbusy = 0; } static void @@ -1467,18 +1474,24 @@ struct ieee80211com *ic = &sc->sc_ic; int error = 0; - RUM_LOCK(sc); - switch (cmd) { case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING){ + RUM_LOCK(sc); rum_update_promisc(sc); - else + RUM_UNLOCK(sc); + } else { + RUM_LOCK(sc); rum_init(sc); + RUM_UNLOCK(sc); + } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING){ + RUM_LOCK(sc); rum_stop(sc); + RUM_UNLOCK(sc); + } } break; default: @@ -1488,12 +1501,13 @@ if (error == ENETRESET) { if ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING) && - (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)) - rum_init(sc); + (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)){ + RUM_LOCK(sc); + rum_init(sc); + RUM_UNLOCK(sc); + } error = 0; } - - RUM_UNLOCK(sc); return error; } --------------050105000400040604070109 Content-Type: text/plain; name="if_rumvar.h.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="if_rumvar.h.diff" --- if_rumvar.h.orig Sun Apr 29 15:32:28 2007 +++ if_rumvar.h Sun Apr 29 15:19:42 2007 @@ -152,6 +152,6 @@ #define RUM_LOCK(sc) mtx_lock(&(sc)->sc_mtx) #define RUM_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) #else -#define RUM_LOCK(sc) -#define RUM_UNLOCK(sc) +#define RUM_LOCK(sc) do { ((sc) = (sc)); mtx_lock(&Giant); } while (0) +#define RUM_UNLOCK(sc) mtx_unlock(&Giant) #endif --------------050105000400040604070109--