From owner-freebsd-current@FreeBSD.ORG Fri Oct 12 03:44:39 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 9E02216A41A for ; Fri, 12 Oct 2007 03:44:39 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by mx1.freebsd.org (Postfix) with ESMTP id 50F5313C46B for ; Fri, 12 Oct 2007 03:44:39 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by wa-out-1112.google.com with SMTP id k17so884160waf for ; Thu, 11 Oct 2007 20:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; bh=/EeDRBjxb5OtF1nTfctrNQyt9w8Go+tHjXnhPAqnV1E=; b=aFg6s6qvvjhKpTHd73+5HwEUndOrujDkL0hNTgw7eh+6nujsUmKuJUtvgPxH/GAiIPYTd7xXMa1hTaAcfvCxaaouDZ8/g6ll6140Bkpw7HqHPfQDNAmcJ5ImkaKBaUKze/rgQu49YGZ5luVfuRevnWqyquAlpaxDlnpgKEutChM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=l1NQ9CtBtdjlktAYIDnJQ4XGm3ZrBiFXcHeOP7bh9uOv5Xfj05M8ab27e7FsqJzTc6ciz9HJJgF/ImTBDjRja33iWLZY7BusyCxV71wZFcRgpbzN0hh2IlV6cBCOLhp4pTwTdvJIKTJoPynHSJ1IvZGaplOe4BqjgyMl+VAcy0k= Received: by 10.114.103.1 with SMTP id a1mr3010699wac.1192160678907; Thu, 11 Oct 2007 20:44:38 -0700 (PDT) Received: from michelle.cdnetworks.co.kr ( [211.53.35.84]) by mx.google.com with ESMTPS id n37sm302305wag.2007.10.11.20.44.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2007 20:44:37 -0700 (PDT) Received: from michelle.cdnetworks.co.kr (localhost.cdnetworks.co.kr [127.0.0.1]) by michelle.cdnetworks.co.kr (8.13.5/8.13.5) with ESMTP id l9C3evRG064211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Oct 2007 12:40:57 +0900 (KST) (envelope-from pyunyh@gmail.com) Received: (from yongari@localhost) by michelle.cdnetworks.co.kr (8.13.5/8.13.5/Submit) id l9C3evVc064210; Fri, 12 Oct 2007 12:40:57 +0900 (KST) (envelope-from pyunyh@gmail.com) Date: Fri, 12 Oct 2007 12:40:57 +0900 From: Pyun YongHyeon To: John Baldwin Message-ID: <20071012034057.GA63854@cdnetworks.co.kr> References: <20070827201809.0367616A418@hub.freebsd.org> <20070828010310.GA85263@cdnetworks.co.kr> <200710101551.26081.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200710101551.26081.jhb@freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: Bill Paul , freebsd-current@freebsd.org, 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 Reply-To: pyunyh@gmail.com List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2007 03:44:39 -0000 On Wed, Oct 10, 2007 at 03:51:25PM -0400, John Baldwin wrote: > 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. > For a record, I've commited the patch to CURRENT/RELENG_7. -- Regards, Pyun YongHyeon