From owner-freebsd-usb@FreeBSD.ORG Sun Feb 1 19:08:27 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A259106566C; Sun, 1 Feb 2009 19:08:27 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from pele.citylink.co.nz (pele.citylink.co.nz [202.8.44.226]) by mx1.freebsd.org (Postfix) with ESMTP id B19FF8FC19; Sun, 1 Feb 2009 19:08:26 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by pele.citylink.co.nz (Postfix) with ESMTP id 220FBFF7A; Mon, 2 Feb 2009 08:08:26 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at citylink.co.nz Received: from pele.citylink.co.nz ([127.0.0.1]) by localhost (pele.citylink.co.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R6gSocjPwblJ; Mon, 2 Feb 2009 08:08:21 +1300 (NZDT) Received: from citylink.fud.org.nz (unknown [202.8.44.45]) by pele.citylink.co.nz (Postfix) with ESMTP; Mon, 2 Feb 2009 08:08:21 +1300 (NZDT) Received: by citylink.fud.org.nz (Postfix, from userid 1001) id 2ED0B1142D; Mon, 2 Feb 2009 08:08:21 +1300 (NZDT) Date: Sun, 1 Feb 2009 11:08:20 -0800 From: Andrew Thompson To: Hans Petter Selasky Message-ID: <20090201190820.GB32503@citylink.fud.org.nz> References: <20090131231957.GB31825@citylink.fud.org.nz> <200902011220.18745.hselasky@c2i.net> <20090201175021.GA32503@citylink.fud.org.nz> <200902011922.16810.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200902011922.16810.hselasky@c2i.net> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-usb@freebsd.org Subject: Re: USB2 patches 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, 01 Feb 2009 19:08:27 -0000 On Sun, Feb 01, 2009 at 07:22:15PM +0100, Hans Petter Selasky wrote: > Hi Andrew, > > > > 3) > > > > > > In general avoid more than a few synchronous USB transfer inside > > > attach/detach. Always defer! Else there are corner cases where the device > > > can hang waiting for the transfer timeout 1-5 seconds for every USB > > > transfer, and that is unacceptable. > > > > I disagree. It hugely simplifies drivers to know all the resources are > > allocated after attach, you dont need to check for null pointers > > throughout the code. > > I think you misunderstand. The attach code that loads firmware, reads eeprom > and performs other configuration must be handed off to another thread, or in > your case a taskqueue, so that the USB attach thread can go on and do other > things. The attach routine allocates resources and attaches the hardware. Things like loading firmware and other configuration are done in the ifnet init routine. > > > It is also very important that you somehow freeze the configuration at > > > the moment a command is issued. For example in the WLAN drivers. If the > > > command is queued when the channel is 5 then we should program channel 5 > > > and not fetch the latest channel value from the softc! IMPORTANT! > > > > This isnt correct. Take your example of WLAN drivers, the net80211 layer > > will use ic_curchan for its logic so the driver needs to program the > > chip to this value at all times. You can _not_ queue channel changes as > > these will be out of sync. > > Being a little off-sync is not the big problem. The big problem is if the > channel value is changing during execution of the code. For example, in the > beginning of the code the channel value is 5, then suddenly it becomes 6, and > the programming just ends up crazy! > > xxx_set_channel() > { > hw_reg = array1[wlan->curchan]; > > write USB register; > > hw_reg = array2[wlan->curchan]; > > write USB register; > } The code should be, xxx_set_channel() { ieee80211_channel c = wlan->curchan; hw_reg = array1[c]; write USB register; hw_reg = array2[c]; write USB register; } cheers, Andrew