From owner-svn-src-all@FreeBSD.ORG Tue Apr 29 21:07:25 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F1CEC70; Tue, 29 Apr 2014 21:07:25 +0000 (UTC) Received: from felyko.com (felyko.com [174.136.100.2]) by mx1.freebsd.org (Postfix) with ESMTP id 12872199F; Tue, 29 Apr 2014 21:07:24 +0000 (UTC) Received: from [10.0.1.3] (c-24-6-115-18.hsd1.ca.comcast.net [24.6.115.18]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by felyko.com (Postfix) with ESMTPSA id BD7033985F; Tue, 29 Apr 2014 14:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=felyko.com; s=mail; t=1398805644; bh=bDoB2Aj+vy2jQMn1UuCpeOQHNfVHQvoP16huskwlxY4=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=G3dlsSggiHm46rvpMG2AXSVYlc4zDESLeNm481bQyvp+JXwArCt80KsgXQAhOnR9F CTYRsLtzEXKLbE7PUnlugIn5Vj6R0wZKTHCkvyyw/ARG1pihL7VbRyhtliFLjVKzbr enFSQOZUL8VPBMG8eZaaH9uREvqS1EcsBEEMVEaw= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: svn commit: r264864 - head/sys/dev/usb/wlan From: Rui Paulo In-Reply-To: <201404240316.s3O3GlUl093950@svn.freebsd.org> Date: Tue, 29 Apr 2014 14:07:21 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <1D92F901-019B-436A-9926-7D7AB4F4C858@felyko.com> References: <201404240316.s3O3GlUl093950@svn.freebsd.org> To: Kevin Lo X-Mailer: Apple Mail (2.1874) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2014 21:07:25 -0000 On Apr 23, 2014, at 20:16, Kevin Lo wrote: > Author: kevlo > Date: Thu Apr 24 03:16:47 2014 > New Revision: 264864 > URL: http://svnweb.freebsd.org/changeset/base/264864 >=20 > Log: > Fix panic by adding mtx_assert() to urtwn_init_locked() and > urtwn_stop_locked(). This was not a panic, but a LOR. > Modified: > head/sys/dev/usb/wlan/if_urtwn.c >=20 > Modified: head/sys/dev/usb/wlan/if_urtwn.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/usb/wlan/if_urtwn.c Thu Apr 24 02:16:23 2014 = (r264863) > +++ head/sys/dev/usb/wlan/if_urtwn.c Thu Apr 24 03:16:47 2014 = (r264864) > @@ -2054,6 +2054,7 @@ urtwn_load_firmware(struct urtwn_softc * > uint32_t reg; > int mlen, ntries, page, error; >=20 > + URTWN_UNLOCK(sc); You didn't need to unlock this early. The problem was in = firmware_get(). > /* Read firmware image from the filesystem. */ > if ((sc->chip & (URTWN_CHIP_UMC_A_CUT | URTWN_CHIP_92C)) =3D=3D > URTWN_CHIP_UMC_A_CUT) > @@ -2062,6 +2063,7 @@ urtwn_load_firmware(struct urtwn_softc * > imagename =3D "urtwn-rtl8192cfwT"; >=20 > fw =3D firmware_get(imagename); > + URTWN_LOCK(sc); > if (fw =3D=3D NULL) { > device_printf(sc->sc_dev, > "failed loadfirmware of file %s\n", imagename); > @@ -2816,6 +2818,8 @@ urtwn_init_locked(void *arg) > uint32_t reg; > int error; >=20 > + URTWN_ASSERT_LOCKED(sc); > + > if (ifp->if_drv_flags & IFF_DRV_RUNNING) > urtwn_stop_locked(ifp); >=20 > @@ -2979,6 +2983,8 @@ urtwn_stop_locked(struct ifnet *ifp) > { > struct urtwn_softc *sc =3D ifp->if_softc; >=20 > + URTWN_ASSERT_LOCKED(sc); > + > ifp->if_drv_flags &=3D ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); >=20 > callout_stop(&sc->sc_watchdog_ch); This is fine, but I wonder if the firmware API should be changed. The = problem with this approach, and all USB WiFi drivers, is that by = unlocking the mutex, the mutual exclusion protection is lost...=20 -- Rui Paulo