From owner-freebsd-current@FreeBSD.ORG Wed Oct 10 20:21:23 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E5E816A419 for ; Wed, 10 Oct 2007 20:21:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 0604E13C43E for ; Wed, 10 Oct 2007 20:21:22 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8p) with ESMTP id 213848287-1834499 for multiple; Wed, 10 Oct 2007 16:19:26 -0400 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l9AKL3aX017064; Wed, 10 Oct 2007 16:21:20 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org, pyunyh@gmail.com Date: Wed, 10 Oct 2007 15:51:25 -0400 User-Agent: KMail/1.9.6 References: <20070827201809.0367616A418@hub.freebsd.org> <20070828010310.GA85263@cdnetworks.co.kr> In-Reply-To: <20070828010310.GA85263@cdnetworks.co.kr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710101551.26081.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 10 Oct 2007 16:21:20 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/4523/Wed Oct 10 14:30:26 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Bill Paul , freebsd-net@freebsd.org Subject: Re: Bug in vr(4) driver X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Oct 2007 20:21:23 -0000 On Monday 27 August 2007 09:03:10 pm Pyun YongHyeon wrote: > On Mon, Aug 27, 2007 at 08:18:08PM +0000, Bill Paul wrote: > > > > I recently started writing a driver for the Via Rhine family of chips > > for VxWorks (they turn up on various x86-based single board systems, > > and I figured it'd be nice to actually support them out of the box), > > and along the way, I noticed a subtle bug in the FreeBSD vr(4) driver. > > > > The vr_attach() routine unconditionally does this for all supported > > chips: > > > > /* > > * Windows may put the chip in suspend mode when it > > * shuts down. Be sure to kick it in the head to wake it > > * up again. > > */ > > VR_CLRBIT(sc, VR_STICKHW, (VR_STICKHW_DS0|VR_STICKHW_DS1)); > > > > The problem is, the VR_STICKHW register is not valid on all Rhine > > devices. The VT86C100A chip, which is present on the D-Link DFE-530TX > > boards, doesn't support power management, and its register space is > > only 128 bytes wide. The VR_STICKHW register offset falls outside this > > range. This may go unnoticed in most scenarios, but if you happen to have > > another PCI device in your system which is assigned the register > > space immediately after that of the Rhine, the vr(4) driver will > > incorrectly stomp it. In my case, the BIOS on my test board decided > > to put the register space for my PRO/100 ethernet board right next > > to the Rhine, and the Rhine driver ended up clobbering the IMR register > > of the PRO/100 device. (Long story short: the board kept locking up on > > boot. Took me the better part of the morning suss out why.) > > > > The strictly correct thing to do would be to check the PCI config space > > to make sure the device supports the power management capability and only > > write to the VR_STICKHW register if it does. A less strictly correct > > but equally effective thing to do would be: > > > > /* > > * Windows may put the chips that support power management into > > * suspend mode when it shuts down. Be sure to kick it in the > > * head to wake it up again. > > */ > > if (pci_get_device(dev) != VIA_DEVICEID_RHINE) > > VR_CLRBIT(sc, VR_STICKHW, (VR_STICKHW_DS0|VR_STICKHW_DS1)); > > > > This is basically the fix I put into my VxWorks driver. I suggest someone > > update the FreeBSD driver as well. > > > > Hi, > > I don't have vr(4) hardwares(if I had I would have converted vr(4) > to use bus_dma(9)). Would you review/test the attached patch? Pyun, I'd say to go ahead and commit the patch. -- John Baldwin