From owner-svn-src-stable@FreeBSD.ORG Sun Oct 25 00:28:02 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3038106566C; Sun, 25 Oct 2009 00:28:01 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A81B58FC15; Sun, 25 Oct 2009 00:28:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9P0S1BU020289; Sun, 25 Oct 2009 00:28:01 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9P0S1CJ020287; Sun, 25 Oct 2009 00:28:01 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <200910250028.n9P0S1CJ020287@svn.freebsd.org> From: Ken Smith Date: Sun, 25 Oct 2009 00:28:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198456 - stable/8/sys/conf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 00:28:02 -0000 Author: kensmith Date: Sun Oct 25 00:28:01 2009 New Revision: 198456 URL: http://svn.freebsd.org/changeset/base/198456 Log: Prepare for 8.0-RC2 builds. Approved by: re (implicit) Modified: stable/8/sys/conf/newvers.sh Modified: stable/8/sys/conf/newvers.sh ============================================================================== --- stable/8/sys/conf/newvers.sh Sun Oct 25 00:26:24 2009 (r198455) +++ stable/8/sys/conf/newvers.sh Sun Oct 25 00:28:01 2009 (r198456) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="8.0" -BRANCH="RC1" +BRANCH="RC2" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-stable@FreeBSD.ORG Sun Oct 25 01:44:12 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 165AE106566B; Sun, 25 Oct 2009 01:44:12 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 96E2D8FC0A; Sun, 25 Oct 2009 01:44:11 +0000 (UTC) Received: from mail14.syd.optusnet.com.au (mail14.syd.optusnet.com.au [211.29.132.195]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n9P0CdIs023413; Sun, 25 Oct 2009 11:12:39 +1100 Received: from server.vk2pj.dyndns.org (c122-106-233-13.belrs3.nsw.optusnet.com.au [122.106.233.13]) by mail14.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n9P0CarC025885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Oct 2009 11:12:37 +1100 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.3/8.14.3) with ESMTP id n9P0CVRC018922; Sun, 25 Oct 2009 11:12:31 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.3/8.14.3/Submit) id n9P0CVlP018908; Sun, 25 Oct 2009 11:12:31 +1100 (EST) (envelope-from peter) Date: Sun, 25 Oct 2009 11:12:31 +1100 From: Peter Jeremy To: Alexander Kabaev Message-ID: <20091025001231.GA1817@server.vk2pj.dyndns.org> References: <200910201905.n9KJ5hPe075884@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: <200910201905.n9KJ5hPe075884@svn.freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r198304 - in stable/8/lib/libc: . gen stdio stdtime string sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 01:44:12 -0000 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2009-Oct-20 19:05:43 +0000, Alexander Kabaev wrote: > Make libc.a provide __stack_chk_fail_local weak alias. This is > needed to satisfy static libraries that are compiled with -fpic > and linked into static binary afterwards. Several libraries in > gcc are examples of such static libs. bin/139052 discusses a related problem not addressed by r197277. Any chance of looking into that? --=20 Peter Jeremy --PNTmBPCT7hxwcZjr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAkrjl+8ACgkQ/opHv/APuIcCAgCgoGsUwwZ+6/ENgZLM1QUjhAsM mkUAoIX29qTq+sLRlwpUjvbaSCOt2xcc =Om1V -----END PGP SIGNATURE----- --PNTmBPCT7hxwcZjr-- From owner-svn-src-stable@FreeBSD.ORG Sun Oct 25 02:53:16 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12C1F106566B; Sun, 25 Oct 2009 02:53:16 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-qy0-f176.google.com (mail-qy0-f176.google.com [209.85.221.176]) by mx1.freebsd.org (Postfix) with ESMTP id 77BDA8FC17; Sun, 25 Oct 2009 02:53:15 +0000 (UTC) Received: by qyk6 with SMTP id 6so4418179qyk.3 for ; Sat, 24 Oct 2009 19:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=1RA/439RJPc429P/vSEgOobHciy6omycPk/yUB+kFcw=; b=ZBwvhAiz9R8bhzmM1Hig7EpGxxP+OnzbQ4tkIGzSSAZcIqXYwOTt0jApDKw6fg4C/F eEArltCRyx7icG6eT6EfXU/Iy7nMMFRIPiUBd2O73n8F2kaMpFu/a1O1kSB0hO+fB1QP hpMQ2NuluGfJD2RiIilLiH2eLqmVIYizb9m/w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=r8abgJx/wT6h9tDtjsNk5MW6DeJPOJkcl2uDkkDhiIdediB6D49lpaXqfc3HnqN+Ew DIbZ2AJE68DgnVCNu1hHqJKAVl8BrhT5KcLSakGI6fjNfho3leT/zKi8bZveMvdXj7iq SA51UDAKopYIM3AFnaikaReHWBiA95Z9RiDS4= Received: by 10.224.110.65 with SMTP id m1mr6438979qap.225.1256437447557; Sat, 24 Oct 2009 19:24:07 -0700 (PDT) Received: from kan.dnsalias.net (c-24-91-218-112.hsd1.ma.comcast.net [24.91.218.112]) by mx.google.com with ESMTPS id 6sm6265970qwk.44.2009.10.24.19.24.06 (version=SSLv3 cipher=RC4-MD5); Sat, 24 Oct 2009 19:24:06 -0700 (PDT) Date: Sat, 24 Oct 2009 22:24:00 -0400 From: Alexander Kabaev To: Peter Jeremy Message-ID: <20091024222400.6575c6f6@kan.dnsalias.net> In-Reply-To: <20091025001231.GA1817@server.vk2pj.dyndns.org> References: <200910201905.n9KJ5hPe075884@svn.freebsd.org> <20091025001231.GA1817@server.vk2pj.dyndns.org> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.6; amd64-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/88nP58oMYfOLq1VZXABL6ZY"; protocol="application/pgp-signature" Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r198304 - in stable/8/lib/libc: . gen stdio stdtime string sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 02:53:16 -0000 --Sig_/88nP58oMYfOLq1VZXABL6ZY Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Sun, 25 Oct 2009 11:12:31 +1100 Peter Jeremy wrote: > On 2009-Oct-20 19:05:43 +0000, Alexander Kabaev > wrote: > > Make libc.a provide __stack_chk_fail_local weak alias. This is > > needed to satisfy static libraries that are compiled with -fpic > > and linked into static binary afterwards. Several libraries in > > gcc are examples of such static libs. >=20 > bin/139052 discusses a related problem not addressed by r197277. > Any chance of looking into that? >=20 > --=20 > Peter Jeremy You are linking in a library compiled with -fstack-protector (libgcov) and do not pass -fstack-protector when running gcc with -fprofile-generator. Consequently, gcc does not link in necessary libssp_nonshared.a. Either you use stack protections or you do not. Please choose. --=20 Alexander Kabaev --Sig_/88nP58oMYfOLq1VZXABL6ZY Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iD8DBQFK47bFQ6z1jMm+XZYRAgKSAJ9MZvvkC1b+/zIcq+lIowx9QvD8yQCeNw06 LM+R90brsp3zglQxbhJv7uM= =EBAD -----END PGP SIGNATURE----- --Sig_/88nP58oMYfOLq1VZXABL6ZY-- From owner-svn-src-stable@FreeBSD.ORG Sun Oct 25 07:27:41 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A2261065670; Sun, 25 Oct 2009 07:27:40 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from mail14.syd.optusnet.com.au (mail14.syd.optusnet.com.au [211.29.132.195]) by mx1.freebsd.org (Postfix) with ESMTP id 768C78FC15; Sun, 25 Oct 2009 07:27:40 +0000 (UTC) Received: from server.vk2pj.dyndns.org (c122-106-233-13.belrs3.nsw.optusnet.com.au [122.106.233.13]) by mail14.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n9P7RZvO022143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Oct 2009 18:27:35 +1100 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.3/8.14.3) with ESMTP id n9P7RXno001952; Sun, 25 Oct 2009 18:27:33 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.3/8.14.3/Submit) id n9P7RXCK001951; Sun, 25 Oct 2009 18:27:33 +1100 (EST) (envelope-from peter) Date: Sun, 25 Oct 2009 18:27:33 +1100 From: Peter Jeremy To: Alexander Kabaev Message-ID: <20091025072732.GA1898@server.vk2pj.dyndns.org> References: <200910201905.n9KJ5hPe075884@svn.freebsd.org> <20091025001231.GA1817@server.vk2pj.dyndns.org> <20091024222400.6575c6f6@kan.dnsalias.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: <20091024222400.6575c6f6@kan.dnsalias.net> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r198304 - in stable/8/lib/libc: . gen stdio stdtime string sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 07:27:41 -0000 --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2009-Oct-24 22:24:00 -0400, Alexander Kabaev wrote: >> bin/139052 discusses a related problem not addressed by r197277. >> Any chance of looking into that? > >You are linking in a library compiled with -fstack-protector >(libgcov) and do not pass -fstack-protector when running gcc with >-fprofile-generator. Consequently, gcc does not link in necessary >libssp_nonshared.a. Well, that explains what is broken. >Either you use stack protections or you do not. Please choose. I haven't specified to use stack protection _anywhere_. The system defaults appear to have been changed so that libgcov is (by default) built with stack protection enabled but gcc doesn't build with stack protection enabled by default, leading to the breakage I reported. This is a POLA violation at best and isn't documented anywhere. If world is going to be built with stack protection on by default then the gcc defaults need to be adjusted to suit. I bumped into this bug whilst trying to build multimedia/x264 with PGO enabled. I'm sure I'm not the only person who is going to get bitten. --=20 Peter Jeremy --EeQfGwPcQSOJBaQU Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAkrj/eQACgkQ/opHv/APuIfskACbBAmE97dhPBgm9wPoUES4BTk4 HmgAnR2CPkU3YL+pybd7tMgrQTxi4kCm =4g2V -----END PGP SIGNATURE----- --EeQfGwPcQSOJBaQU-- From owner-svn-src-stable@FreeBSD.ORG Mon Oct 26 18:57:58 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9486106566B; Mon, 26 Oct 2009 18:57:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3ACE8FC18; Mon, 26 Oct 2009 18:57:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9QIvvxQ000117; Mon, 26 Oct 2009 18:57:57 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9QIvvcZ000107; Mon, 26 Oct 2009 18:57:57 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200910261857.n9QIvvcZ000107@svn.freebsd.org> From: John Baldwin Date: Mon, 26 Oct 2009 18:57:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198496 - in stable/7: etc etc/mtree include sys sys/contrib/pf sys/dev/mfi usr.sbin usr.sbin/acpi usr.sbin/adduser usr.sbin/arp usr.sbin/bluetooth usr.sbin/bluetooth/btpand usr.sbin/bl... X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2009 18:57:58 -0000 Author: jhb Date: Mon Oct 26 18:57:57 2009 New Revision: 198496 URL: http://svn.freebsd.org/changeset/base/198496 Log: MFC 196200,196211,196280-196282: Introduce mfiutil, a basic utility for managing LSI SAS-RAID & Dell PERC5/6 controllers. Controller, array, and drive status can be checked, basic attributes can be changed, and arrays and spares can be created and deleted. Controller firmware can also be flashed. This does not replace MegaCLI, found in ports, as that is officially sanctioned and supported by LSI and includes vastly more functionality. However, mfiutil is open source and guaranteed to provide basic functionality, which can be especially useful if you have a problem and can't get MegaCLI to work. Added: stable/7/usr.sbin/mfiutil/ (props changed) - copied from r196200, head/usr.sbin/mfiutil/ stable/7/usr.sbin/mfiutil/mfiutil.8 (contents, props changed) - copied, changed from r196280, head/usr.sbin/mfiutil/mfiutil.8 Modified: stable/7/etc/ (props changed) stable/7/etc/mtree/BSD.include.dist stable/7/etc/termcap.small (props changed) stable/7/include/ (props changed) stable/7/include/Makefile stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/mfi/mfi_ioctl.h stable/7/sys/dev/mfi/mfireg.h stable/7/usr.sbin/ (props changed) stable/7/usr.sbin/Makefile stable/7/usr.sbin/acpi/ (props changed) stable/7/usr.sbin/adduser/ (props changed) stable/7/usr.sbin/arp/ (props changed) stable/7/usr.sbin/bluetooth/ (props changed) stable/7/usr.sbin/bluetooth/btpand/ (props changed) stable/7/usr.sbin/bluetooth/hcsecd/ (props changed) stable/7/usr.sbin/bluetooth/hcseriald/ (props changed) stable/7/usr.sbin/bluetooth/rfcomm_pppd/ (props changed) stable/7/usr.sbin/bluetooth/sdpd/ (props changed) stable/7/usr.sbin/bsnmpd/modules/snmp_pf/ (props changed) stable/7/usr.sbin/burncd/ (props changed) stable/7/usr.sbin/cdcontrol/ (props changed) stable/7/usr.sbin/chown/ (props changed) stable/7/usr.sbin/chroot/ (props changed) stable/7/usr.sbin/config/ (props changed) stable/7/usr.sbin/cpucontrol/ (props changed) stable/7/usr.sbin/crashinfo/ (props changed) stable/7/usr.sbin/cron/ (props changed) stable/7/usr.sbin/cron/cron/ (props changed) stable/7/usr.sbin/crunch/ (props changed) stable/7/usr.sbin/eeprom/ (props changed) stable/7/usr.sbin/extattr/ (props changed) stable/7/usr.sbin/fdcontrol/ (props changed) stable/7/usr.sbin/fdformat/ (props changed) stable/7/usr.sbin/fdread/ (props changed) stable/7/usr.sbin/fdwrite/ (props changed) stable/7/usr.sbin/freebsd-update/ (props changed) stable/7/usr.sbin/fwcontrol/ (props changed) stable/7/usr.sbin/gstat/ (props changed) stable/7/usr.sbin/iostat/ (props changed) stable/7/usr.sbin/jail/ (props changed) stable/7/usr.sbin/jexec/ (props changed) stable/7/usr.sbin/jls/ (props changed) stable/7/usr.sbin/lpr/ (props changed) stable/7/usr.sbin/makefs/ (props changed) stable/7/usr.sbin/makefs/ffs/ffs_bswap.c (props changed) stable/7/usr.sbin/makefs/ffs/ffs_subr.c (props changed) stable/7/usr.sbin/makefs/ffs/ufs_bswap.h (props changed) stable/7/usr.sbin/makefs/getid.c (props changed) stable/7/usr.sbin/mergemaster/ (props changed) stable/7/usr.sbin/mfiutil/Makefile stable/7/usr.sbin/mfiutil/mfi_drive.c stable/7/usr.sbin/mountd/ (props changed) stable/7/usr.sbin/mtree/ (props changed) stable/7/usr.sbin/ndiscvt/ (props changed) stable/7/usr.sbin/newsyslog/newsyslog.conf.5 (props changed) stable/7/usr.sbin/nscd/ (props changed) stable/7/usr.sbin/ntp/ (props changed) stable/7/usr.sbin/pciconf/ (props changed) stable/7/usr.sbin/pkg_install/ (props changed) stable/7/usr.sbin/pmcstat/ (props changed) stable/7/usr.sbin/portsnap/ (props changed) stable/7/usr.sbin/powerd/ (props changed) stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/pstat/ (props changed) stable/7/usr.sbin/pw/ (props changed) stable/7/usr.sbin/pwd_mkdb/ (props changed) stable/7/usr.sbin/rpc.lockd/ (props changed) stable/7/usr.sbin/rpc.statd/ (props changed) stable/7/usr.sbin/rpc.yppasswdd/ (props changed) stable/7/usr.sbin/sade/ (props changed) stable/7/usr.sbin/setfib/ (props changed) stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/syslogd/ (props changed) stable/7/usr.sbin/traceroute/ (props changed) stable/7/usr.sbin/traceroute6/ (props changed) stable/7/usr.sbin/tzsetup/ (props changed) stable/7/usr.sbin/wpa/wpa_supplicant/ (props changed) stable/7/usr.sbin/ypserv/ (props changed) stable/7/usr.sbin/zic/ (props changed) Modified: stable/7/etc/mtree/BSD.include.dist ============================================================================== --- stable/7/etc/mtree/BSD.include.dist Mon Oct 26 18:32:06 2009 (r198495) +++ stable/7/etc/mtree/BSD.include.dist Mon Oct 26 18:57:57 2009 (r198496) @@ -102,6 +102,8 @@ .. lmc .. + mfi + .. mpt mpilib .. Modified: stable/7/include/Makefile ============================================================================== --- stable/7/include/Makefile Mon Oct 26 18:32:06 2009 (r198495) +++ stable/7/include/Makefile Mon Oct 26 18:57:57 2009 (r198496) @@ -43,7 +43,7 @@ LDIRS= bsm cam geom net net80211 netatal LSUBDIRS= cam/scsi \ dev/acpica dev/an dev/bktr dev/firewire dev/hwpmc \ - dev/ic dev/iicbus ${_dev_ieee488} dev/lmc dev/ofw \ + dev/ic dev/iicbus ${_dev_ieee488} dev/lmc dev/mfi dev/ofw \ dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ fs/devfs fs/fdescfs fs/fifofs fs/msdosfs fs/ntfs fs/nullfs \ Modified: stable/7/sys/dev/mfi/mfi_ioctl.h ============================================================================== --- stable/7/sys/dev/mfi/mfi_ioctl.h Mon Oct 26 18:32:06 2009 (r198495) +++ stable/7/sys/dev/mfi/mfi_ioctl.h Mon Oct 26 18:57:57 2009 (r198496) @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +#include + #if defined(__amd64__) /* Assume amd64 wants 32 bit Linux */ struct iovec32 { u_int32_t iov_base; Modified: stable/7/sys/dev/mfi/mfireg.h ============================================================================== --- stable/7/sys/dev/mfi/mfireg.h Mon Oct 26 18:32:06 2009 (r198495) +++ stable/7/sys/dev/mfi/mfireg.h Mon Oct 26 18:57:57 2009 (r198496) @@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$"); #define MFI_ODCR0 0xa0 /* outbound doorbell clear register0 */ #define MFI_OSP0 0xb0 /* outbound scratch pad0 */ #define MFI_1078_EIM 0x80000004 /* 1078 enable intrrupt mask */ -#define MFI_RMI 0x2 /* reply message interrupt */ +#define MFI_RMI 0x2 /* reply message interrupt */ #define MFI_1078_RM 0x80000000 /* reply 1078 message interrupt */ #define MFI_ODC 0x4 /* outbound doorbell change interrupt */ @@ -151,15 +151,41 @@ typedef enum { MFI_DCMD_CTRL_EVENT_GETINFO = 0x01040100, MFI_DCMD_CTRL_EVENT_GET = 0x01040300, MFI_DCMD_CTRL_EVENT_WAIT = 0x01040500, + MFI_DCMD_PR_GET_STATUS = 0x01070100, + MFI_DCMD_PR_GET_PROPERTIES = 0x01070200, + MFI_DCMD_PR_SET_PROPERTIES = 0x01070300, + MFI_DCMD_PR_START = 0x01070400, + MFI_DCMD_PR_STOP = 0x01070500, + MFI_DCMD_TIME_SECS_GET = 0x01080201, + MFI_DCMD_FLASH_FW_OPEN = 0x010f0100, + MFI_DCMD_FLASH_FW_DOWNLOAD = 0x010f0200, + MFI_DCMD_FLASH_FW_FLASH = 0x010f0300, + MFI_DCMD_FLASH_FW_CLOSE = 0x010f0400, + MFI_DCMD_PD_GET_LIST = 0x02010000, + MFI_DCMD_PD_GET_INFO = 0x02020000, + MFI_DCMD_PD_STATE_SET = 0x02030100, + MFI_DCMD_PD_REBUILD_START = 0x02040100, + MFI_DCMD_PD_REBUILD_ABORT = 0x02040200, + MFI_DCMD_PD_CLEAR_START = 0x02050100, + MFI_DCMD_PD_CLEAR_ABORT = 0x02050200, + MFI_DCMD_PD_GET_PROGRESS = 0x02060000, + MFI_DCMD_PD_LOCATE_START = 0x02070100, + MFI_DCMD_PD_LOCATE_STOP = 0x02070200, MFI_DCMD_LD_GET_LIST = 0x03010000, MFI_DCMD_LD_GET_INFO = 0x03020000, MFI_DCMD_LD_GET_PROP = 0x03030000, MFI_DCMD_LD_SET_PROP = 0x03040000, + MFI_DCMD_LD_INIT_START = 0x03060100, MFI_DCMD_LD_DELETE = 0x03090000, MFI_DCMD_CFG_READ = 0x04010000, MFI_DCMD_CFG_ADD = 0x04020000, MFI_DCMD_CFG_CLEAR = 0x04030000, + MFI_DCMD_CFG_MAKE_SPARE = 0x04040000, + MFI_DCMD_CFG_REMOVE_SPARE = 0x04050000, MFI_DCMD_CFG_FOREIGN_IMPORT = 0x04060400, + MFI_DCMD_BBU_GET_STATUS = 0x05010000, + MFI_DCMD_BBU_GET_CAPACITY_INFO =0x05020000, + MFI_DCMD_BBU_GET_DESIGN_INFO = 0x05030000, MFI_DCMD_CLUSTER = 0x08000000, MFI_DCMD_CLUSTER_RESET_ALL = 0x08010100, MFI_DCMD_CLUSTER_RESET_LD = 0x08010200 @@ -245,6 +271,9 @@ typedef enum { MFI_STAT_RESERVATION_IN_PROGRESS, MFI_STAT_I2C_ERRORS_DETECTED, MFI_STAT_PCI_ERRORS_DETECTED, + MFI_STAT_DIAG_FAILED, + MFI_STAT_BOOT_MSG_PENDING, + MFI_STAT_FOREIGN_CONFIG_INCOMPLETE, MFI_STAT_INVALID_STATUS = 0xFF } mfi_status_t; @@ -303,6 +332,17 @@ typedef enum { MR_LD_CACHE_ALLOW_WRITE_CACHE = 0x20, MR_LD_CACHE_ALLOW_READ_CACHE = 0x40 } mfi_ld_cache; +#define MR_LD_CACHE_MASK 0x7f + +#define MR_LD_CACHE_POLICY_READ_AHEAD_NONE 0 +#define MR_LD_CACHE_POLICY_READ_AHEAD_ALWAYS MR_LD_CACHE_READ_AHEAD +#define MR_LD_CACHE_POLICY_READ_AHEAD_ADAPTIVE \ + (MR_LD_CACHE_READ_AHEAD | MR_LD_CACHE_READ_ADAPTIVE) +#define MR_LD_CACHE_POLICY_WRITE_THROUGH 0 +#define MR_LD_CACHE_POLICY_WRITE_BACK MR_LD_CACHE_WRITE_BACK +#define MR_LD_CACHE_POLICY_IO_CACHED \ + (MR_LD_CACHE_ALLOW_WRITE_CACHE | MR_LD_CACHE_ALLOW_READ_CACHE) +#define MR_LD_CACHE_POLICY_IO_DIRECT 0 typedef enum { MR_PD_CACHE_UNCHANGED = 0, @@ -320,6 +360,7 @@ typedef enum { #define MFI_DEFAULT_ID -1 #define MFI_MAX_LUN 8 #define MFI_MAX_LD 64 +#define MFI_MAX_PD 256 #define MFI_FRAME_SIZE 64 #define MFI_MBOX_SIZE 12 @@ -866,12 +907,10 @@ union mfi_pd_ddf_type { } __packed; struct mfi_pd_progress { - struct { - uint32_t rbld : 1; - uint32_t patrol : 1; - uint32_t clear : 1; - uint32_t reserved: 29; - } active; + uint32_t active; +#define MFI_PD_PROGRESS_REBUILD (1<<0) +#define MFI_PD_PROGRESS_PATROL (1<<1) +#define MFI_PD_PROGRESS_CLEAR (1<<2) struct mfi_progress rbld; struct mfi_progress patrol; struct mfi_progress clear; @@ -890,8 +929,8 @@ struct mfi_pd_info { uint32_t other_err_count; uint32_t pred_fail_count; uint32_t last_pred_fail_event_seq_num; - uint16_t fw_state; - uint8_t disable_for_removal; + uint16_t fw_state; /* MFI_PD_STATE_* */ + uint8_t disabled_for_removal; uint8_t link_speed; union mfi_pd_ddf_type state; struct { @@ -918,7 +957,7 @@ struct mfi_pd_address { uint16_t encl_device_id; uint8_t encl_index; uint8_t slot_number; - uint8_t scsi_dev_type; + uint8_t scsi_dev_type; /* 0 = disk */ uint8_t connect_port_bitmap; uint64_t sas_addr[2]; } __packed; @@ -926,12 +965,19 @@ struct mfi_pd_address { struct mfi_pd_list { uint32_t size; uint32_t count; - uint8_t data; - /* - struct mfi_pd_address addr[]; - */ + struct mfi_pd_address addr[0]; } __packed; +enum mfi_pd_state { + MFI_PD_STATE_UNCONFIGURED_GOOD = 0x00, + MFI_PD_STATE_UNCONFIGURED_BAD = 0x01, + MFI_PD_STATE_HOT_SPARE = 0x02, + MFI_PD_STATE_OFFLINE = 0x10, + MFI_PD_STATE_FAILED = 0x11, + MFI_PD_STATE_REBUILD = 0x14, + MFI_PD_STATE_ONLINE = 0x18 +}; + union mfi_ld_ref { struct { uint8_t target_id; @@ -986,6 +1032,9 @@ struct mfi_ld_params { uint8_t span_depth; uint8_t state; uint8_t init_state; +#define MFI_LD_PARAMS_INIT_NO 0 +#define MFI_LD_PARAMS_INIT_QUICK 1 +#define MFI_LD_PARAMS_INIT_FULL 2 uint8_t is_consistent; uint8_t reserved[23]; } __packed; @@ -995,7 +1044,7 @@ struct mfi_ld_progress { #define MFI_LD_PROGRESS_CC (1<<0) #define MFI_LD_PROGRESS_BGI (1<<1) #define MFI_LD_PROGRESS_FGI (1<<2) -#define MFI_LD_PORGRESS_RECON (1<<3) +#define MFI_LD_PROGRESS_RECON (1<<3) struct mfi_progress cc; struct mfi_progress bgi; struct mfi_progress fgi; @@ -1028,26 +1077,18 @@ struct mfi_ld_info { uint8_t reserved2[16]; } __packed; -union mfi_spare_type { - struct { - uint8_t is_dedicate :1; - uint8_t is_revertable :1; - uint8_t is_encl_affinity :1; - uint8_t reserved :5; - } v; - uint8_t type; -} __packed; - #define MAX_ARRAYS 16 struct mfi_spare { union mfi_pd_ref ref; - union mfi_spare_type spare_type; + uint8_t spare_type; +#define MFI_SPARE_DEDICATED (1 << 0) +#define MFI_SPARE_REVERTIBLE (1 << 1) +#define MFI_SPARE_ENCL_AFFINITY (1 << 2) uint8_t reserved[2]; uint8_t array_count; - uint16_t array_refd[MAX_ARRAYS]; + uint16_t array_ref[MAX_ARRAYS]; } __packed; -#define MAX_ROW_SIZE 32 struct mfi_array { uint64_t size; uint8_t num_drives; @@ -1055,13 +1096,13 @@ struct mfi_array { uint16_t array_ref; uint8_t pad[20]; struct { - union mfi_pd_ref ref; - uint16_t fw_state; + union mfi_pd_ref ref; /* 0xffff == missing drive */ + uint16_t fw_state; /* MFI_PD_STATE_* */ struct { uint8_t pd; uint8_t slot; } encl; - } pd[MAX_ROW_SIZE]; + } pd[0]; } __packed; struct mfi_config_data { @@ -1073,13 +1114,117 @@ struct mfi_config_data { uint16_t spares_count; uint16_t spares_size; uint8_t reserved[16]; - uint8_t data; - /* - struct mfi_array array[]; - struct mfi_ld_config ld[]; - struct mfi_spare spare[]; - */ -} __packed; + struct mfi_array array[0]; + struct mfi_ld_config ld[0]; + struct mfi_spare spare[0]; +} __packed; + +struct mfi_bbu_capacity_info { + uint16_t relative_charge; + uint16_t absolute_charge; + uint16_t remaining_capacity; + uint16_t full_charge_capacity; + uint16_t run_time_to_empty; + uint16_t average_time_to_empty; + uint16_t average_time_to_full; + uint16_t cycle_count; + uint16_t max_error; + uint16_t remaining_capacity_alarm; + uint16_t remaining_time_alarm; + uint8_t reserved[26]; +} __packed; + +struct mfi_bbu_design_info { + uint32_t mfg_date; + uint16_t design_capacity; + uint16_t design_voltage; + uint16_t spec_info; + uint16_t serial_number; + uint16_t pack_stat_config; + uint8_t mfg_name[12]; + uint8_t device_name[8]; + uint8_t device_chemistry[8]; + uint8_t mfg_data[8]; + uint8_t reserved[17]; +} __packed; + +struct mfi_ibbu_state { + uint16_t gas_guage_status; + uint16_t relative_charge; + uint16_t charger_system_state; + uint16_t charger_system_ctrl; + uint16_t charging_current; + uint16_t absolute_charge; + uint16_t max_error; + uint8_t reserved[18]; +} __packed; + +struct mfi_bbu_state { + uint16_t gas_guage_status; + uint16_t relative_charge; + uint16_t charger_status; + uint16_t remaining_capacity; + uint16_t full_charge_capacity; + uint8_t is_SOH_good; + uint8_t reserved[21]; +} __packed; + +union mfi_bbu_status_detail { + struct mfi_ibbu_state ibbu; + struct mfi_bbu_state bbu; +}; + +struct mfi_bbu_status { + uint8_t battery_type; +#define MFI_BBU_TYPE_NONE 0 +#define MFI_BBU_TYPE_IBBU 1 +#define MFI_BBU_TYPE_BBU 2 + uint8_t reserved; + uint16_t voltage; + int16_t current; + uint16_t temperature; + uint32_t fw_status; +#define MFI_BBU_STATE_PACK_MISSING (1 << 0) +#define MFI_BBU_STATE_VOLTAGE_LOW (1 << 1) +#define MFI_BBU_STATE_TEMPERATURE_HIGH (1 << 2) +#define MFI_BBU_STATE_CHARGE_ACTIVE (1 << 0) +#define MFI_BBU_STATE_DISCHARGE_ACTIVE (1 << 0) + uint8_t pad[20]; + union mfi_bbu_status_detail detail; +} __packed; + +enum mfi_pr_state { + MFI_PR_STATE_STOPPED = 0, + MFI_PR_STATE_READY = 1, + MFI_PR_STATE_ACTIVE = 2, + MFI_PR_STATE_ABORTED = 0xff +}; + +struct mfi_pr_status { + uint32_t num_iteration; + uint8_t state; + uint8_t num_pd_done; + uint8_t reserved[10]; +}; + +enum mfi_pr_opmode { + MFI_PR_OPMODE_AUTO = 0, + MFI_PR_OPMODE_MANUAL = 1, + MFI_PR_OPMODE_DISABLED = 2 +}; + +struct mfi_pr_properties { + uint8_t op_mode; + uint8_t max_pd; + uint8_t reserved; + uint8_t exclude_ld_count; + uint16_t excluded_ld[MFI_MAX_LD]; + uint8_t cur_pd_map[MFI_MAX_PD / 8]; + uint8_t last_pd_map[MFI_MAX_PD / 8]; + uint32_t next_exec; + uint32_t exec_freq; + uint32_t clear_freq; +}; #define MFI_SCSI_MAX_TARGETS 128 #define MFI_SCSI_MAX_LUNS 8 Modified: stable/7/usr.sbin/Makefile ============================================================================== --- stable/7/usr.sbin/Makefile Mon Oct 26 18:32:06 2009 (r198495) +++ stable/7/usr.sbin/Makefile Mon Oct 26 18:57:57 2009 (r198496) @@ -91,6 +91,7 @@ SUBDIR= ${_ac} \ manctl \ memcontrol \ mergemaster \ + mfiutil \ mixer \ ${_mld6query} \ mlxcontrol \ Modified: stable/7/usr.sbin/mfiutil/Makefile ============================================================================== --- head/usr.sbin/mfiutil/Makefile Thu Aug 13 23:18:45 2009 (r196200) +++ stable/7/usr.sbin/mfiutil/Makefile Mon Oct 26 18:57:57 2009 (r198496) @@ -3,6 +3,7 @@ PROG= mfiutil SRCS= mfiutil.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c mfi_flash.c \ mfi_patrol.c mfi_show.c mfi_volume.c +MAN8= mfiutil.8 CFLAGS+= -fno-builtin-strftime WARNS?=3 Modified: stable/7/usr.sbin/mfiutil/mfi_drive.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_drive.c Thu Aug 13 23:18:45 2009 (r196200) +++ stable/7/usr.sbin/mfiutil/mfi_drive.c Mon Oct 26 18:57:57 2009 (r198496) @@ -75,8 +75,9 @@ int mfi_lookup_drive(int fd, char *drive, uint16_t *device_id) { struct mfi_pd_list *list; - long val; uint8_t encl, slot; + long val; + u_int i; char *cp; /* Look for a raw device id first. */ @@ -117,15 +118,15 @@ mfi_lookup_drive(int fd, char *drive, ui return (errno); } - for (val = 0; val < list->count; val++) { - if (list->addr[val].scsi_dev_type != 0) + for (i = 0; i < list->count; i++) { + if (list->addr[i].scsi_dev_type != 0) continue; if (((encl == 0xff && - list->addr[val].encl_device_id == 0xffff) || - list->addr[val].encl_index == encl) && - list->addr[val].slot_number == slot) { - *device_id = list->addr[val].device_id; + list->addr[i].encl_device_id == 0xffff) || + list->addr[i].encl_index == encl) && + list->addr[i].slot_number == slot) { + *device_id = list->addr[i].device_id; free(list); return (0); } Copied and modified: stable/7/usr.sbin/mfiutil/mfiutil.8 (from r196280, head/usr.sbin/mfiutil/mfiutil.8) ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.8 Mon Aug 17 06:05:55 2009 (r196280, copy source) +++ stable/7/usr.sbin/mfiutil/mfiutil.8 Mon Oct 26 18:57:57 2009 (r198496) @@ -27,8 +27,8 @@ .\" .\" $FreeBSD$ .\" -.Dd June 17, 2008 -.Dt MFIUTIL 1 +.Dd August 16, 2009 +.Dt MFIUTIL 8 .Os .Sh NAME .Nm mfiutil @@ -161,9 +161,6 @@ on the volume may be specified by the co device, such as .Em mfid0 . -Note that this second method only works on OS versions -.Dv 6.2-YAHOO-20070510 -and later. .Pp Drives may be specified in two forms. First, @@ -562,13 +559,8 @@ patrol read starting in 5 minutes: .Pp .Sh SEE ALSO .Xr mfi 4 -.Sh BUGS -On 64-bit OS versions -.Dv 6.2-YAHOO-20070514 -and earlier, -the -.Xr mfi 4 -driver does not properly report firmware errors to 32-bit versions of -.Nm . -As a result, -some commands may fail even though they do not report any errors. +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 8.0 . From owner-svn-src-stable@FreeBSD.ORG Mon Oct 26 19:06:06 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 499DE1065676; Mon, 26 Oct 2009 19:06:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7C5D8FC1B; Mon, 26 Oct 2009 19:06:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9QJ65fh000809; Mon, 26 Oct 2009 19:06:05 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9QJ65Io000806; Mon, 26 Oct 2009 19:06:05 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200910261906.n9QJ65Io000806@svn.freebsd.org> From: John Baldwin Date: Mon, 26 Oct 2009 19:06:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198497 - in stable/7/usr.sbin: . acpi adduser arp bluetooth bluetooth/btpand bluetooth/hcsecd bluetooth/hcseriald bluetooth/rfcomm_pppd bluetooth/sdpd bsnmpd/modules/snmp_pf burncd cdc... X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2009 19:06:06 -0000 Author: jhb Date: Mon Oct 26 19:06:05 2009 New Revision: 198497 URL: http://svn.freebsd.org/changeset/base/198497 Log: MFC 196212,196283: Add mptutil, a basic utility for managing MPT SCSI/SATA/SAS controllers. Drive and controller status can be reported, basic attributes changed, and arrays and spares can be created and deleted. Added: stable/7/usr.sbin/mptutil/ (props changed) - copied from r196212, head/usr.sbin/mptutil/ Modified: stable/7/usr.sbin/ (props changed) stable/7/usr.sbin/Makefile stable/7/usr.sbin/acpi/ (props changed) stable/7/usr.sbin/adduser/ (props changed) stable/7/usr.sbin/arp/ (props changed) stable/7/usr.sbin/bluetooth/ (props changed) stable/7/usr.sbin/bluetooth/btpand/ (props changed) stable/7/usr.sbin/bluetooth/hcsecd/ (props changed) stable/7/usr.sbin/bluetooth/hcseriald/ (props changed) stable/7/usr.sbin/bluetooth/rfcomm_pppd/ (props changed) stable/7/usr.sbin/bluetooth/sdpd/ (props changed) stable/7/usr.sbin/bsnmpd/modules/snmp_pf/ (props changed) stable/7/usr.sbin/burncd/ (props changed) stable/7/usr.sbin/cdcontrol/ (props changed) stable/7/usr.sbin/chown/ (props changed) stable/7/usr.sbin/chroot/ (props changed) stable/7/usr.sbin/config/ (props changed) stable/7/usr.sbin/cpucontrol/ (props changed) stable/7/usr.sbin/crashinfo/ (props changed) stable/7/usr.sbin/cron/ (props changed) stable/7/usr.sbin/cron/cron/ (props changed) stable/7/usr.sbin/crunch/ (props changed) stable/7/usr.sbin/eeprom/ (props changed) stable/7/usr.sbin/extattr/ (props changed) stable/7/usr.sbin/fdcontrol/ (props changed) stable/7/usr.sbin/fdformat/ (props changed) stable/7/usr.sbin/fdread/ (props changed) stable/7/usr.sbin/fdwrite/ (props changed) stable/7/usr.sbin/freebsd-update/ (props changed) stable/7/usr.sbin/fwcontrol/ (props changed) stable/7/usr.sbin/gstat/ (props changed) stable/7/usr.sbin/iostat/ (props changed) stable/7/usr.sbin/jail/ (props changed) stable/7/usr.sbin/jexec/ (props changed) stable/7/usr.sbin/jls/ (props changed) stable/7/usr.sbin/lpr/ (props changed) stable/7/usr.sbin/makefs/ (props changed) stable/7/usr.sbin/makefs/ffs/ffs_bswap.c (props changed) stable/7/usr.sbin/makefs/ffs/ffs_subr.c (props changed) stable/7/usr.sbin/makefs/ffs/ufs_bswap.h (props changed) stable/7/usr.sbin/makefs/getid.c (props changed) stable/7/usr.sbin/mergemaster/ (props changed) stable/7/usr.sbin/mfiutil/ (props changed) stable/7/usr.sbin/mfiutil/mfiutil.8 (props changed) stable/7/usr.sbin/mountd/ (props changed) stable/7/usr.sbin/mptutil/mptutil.8 stable/7/usr.sbin/mtree/ (props changed) stable/7/usr.sbin/ndiscvt/ (props changed) stable/7/usr.sbin/newsyslog/newsyslog.conf.5 (props changed) stable/7/usr.sbin/nscd/ (props changed) stable/7/usr.sbin/ntp/ (props changed) stable/7/usr.sbin/pciconf/ (props changed) stable/7/usr.sbin/pkg_install/ (props changed) stable/7/usr.sbin/pmcstat/ (props changed) stable/7/usr.sbin/portsnap/ (props changed) stable/7/usr.sbin/powerd/ (props changed) stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/pstat/ (props changed) stable/7/usr.sbin/pw/ (props changed) stable/7/usr.sbin/pwd_mkdb/ (props changed) stable/7/usr.sbin/rpc.lockd/ (props changed) stable/7/usr.sbin/rpc.statd/ (props changed) stable/7/usr.sbin/rpc.yppasswdd/ (props changed) stable/7/usr.sbin/sade/ (props changed) stable/7/usr.sbin/setfib/ (props changed) stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/syslogd/ (props changed) stable/7/usr.sbin/traceroute/ (props changed) stable/7/usr.sbin/traceroute6/ (props changed) stable/7/usr.sbin/tzsetup/ (props changed) stable/7/usr.sbin/wpa/wpa_supplicant/ (props changed) stable/7/usr.sbin/ypserv/ (props changed) stable/7/usr.sbin/zic/ (props changed) Modified: stable/7/usr.sbin/Makefile ============================================================================== --- stable/7/usr.sbin/Makefile Mon Oct 26 18:57:57 2009 (r198496) +++ stable/7/usr.sbin/Makefile Mon Oct 26 19:06:05 2009 (r198497) @@ -101,6 +101,7 @@ SUBDIR= ${_ac} \ ${_mount_smbfs} \ ${_moused} \ ${_mptable} \ + mptutil \ mtest \ mtree \ ${_named} \ Modified: stable/7/usr.sbin/mptutil/mptutil.8 ============================================================================== --- head/usr.sbin/mptutil/mptutil.8 Fri Aug 14 13:13:12 2009 (r196212) +++ stable/7/usr.sbin/mptutil/mptutil.8 Mon Oct 26 19:06:05 2009 (r198497) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 22, 2008 +.Dd August 16, 2009 .Dt MPTUTIL 8 .Os .Sh NAME @@ -349,8 +349,6 @@ as a global hot spare: .Sh SEE ALSO .Xr mpt 4 .Sh BUGS -Deleting volumes usually provokes a kernel crash in OS versions older than -.Dv 6.3-YAHOO-20080722 . .Pp The handling of spare drives appears to be unreliable. The @@ -381,3 +379,8 @@ configurations may not work reliably. .Pp Drive configuration commands result in an excessive flood of messages on the console. +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 8.0 . From owner-svn-src-stable@FreeBSD.ORG Mon Oct 26 19:43:59 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AED9E106568D; Mon, 26 Oct 2009 19:43:59 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-fx0-f210.google.com (mail-fx0-f210.google.com [209.85.220.210]) by mx1.freebsd.org (Postfix) with ESMTP id 1BF258FC1E; Mon, 26 Oct 2009 19:43:58 +0000 (UTC) Received: by fxm6 with SMTP id 6so11647198fxm.43 for ; Mon, 26 Oct 2009 12:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=kv3WhDxXkF/G1FZqZSw8VstblGV6rptZB9LmV3yfXME=; b=w5dRW5i3qadXKYc+r/QOLc6fosgcCUaVSHgTP50P7x+buonBz4o+EhraKBJShh1210 vFYqopZ+NjEzkY8uP5ucyYwrTx09ZmYRN9ED6fbMdORyc5j6q6m99bTHARtwVxf76t+H Xod83WsJMuSOAK7cMh8ZzoZzH9WJQb4n9HSAE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=TN91+75UTX6vCeEGGidDed77/847i1hlz+BsqcJiMxkN3slZLX7Na0NSI7301qqi8z bY3CtwNNdUNsBtgknD4wSlgK87WaXJ0N+bLDkGKg1ZlcktkMcz1dRq7BJ/+2taeDixfY IRtxhTR4D2W38dL2nTE83IX7L+kJdElZMQCks= MIME-Version: 1.0 Received: by 10.204.33.7 with SMTP id f7mr4687916bkd.123.1256584872296; Mon, 26 Oct 2009 12:21:12 -0700 (PDT) In-Reply-To: <200910261857.n9QIvvcZ000107@svn.freebsd.org> References: <200910261857.n9QIvvcZ000107@svn.freebsd.org> Date: Mon, 26 Oct 2009 22:21:10 +0300 Message-ID: From: pluknet To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r198496 - in stable/7: etc etc/mtree include sys sys/contrib/pf sys/dev/mfi usr.sbin usr.sbin/acpi usr.sbin/adduser usr.sbin/arp usr.sbin/bluetooth usr.sbin/bluetooth/btpand usr.sbin/bl... X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2009 19:43:59 -0000 2009/10/26 John Baldwin : > Author: jhb > Date: Mon Oct 26 18:57:57 2009 > New Revision: 198496 > URL: http://svn.freebsd.org/changeset/base/198496 > > Log: > =A0MFC 196200,196211,196280-196282: > =A0Introduce mfiutil, a basic utility for managing LSI SAS-RAID & Dell PE= RC5/6 > =A0controllers. =A0Controller, array, and drive status can be checked, ba= sic > =A0attributes can be changed, and arrays and spares can be created and de= leted. > =A0Controller firmware can also be flashed. > > =A0This does not replace MegaCLI, found in ports, as that is officially s= anctioned > =A0and supported by LSI and includes vastly more functionality. =A0Howeve= r, mfiutil > =A0is open source and guaranteed to provide basic functionality, which ca= n be > =A0especially useful if you have a problem and can't get MegaCLI to work. > John, thank you very much for mfc'ing those nice mfi- and mptutil! It's interesting to know if this can be mfc'ed to 6 safely in principle, without breaking some of existing interfaces. I tried to use both on 6, and my experience was quite successful. > +.Sh HISTORY > +The > +.Nm > +utility first appeared in > +.Fx 8.0 . Please don't forget to change it to 7.3. Thank you again! --=20 wbr, pluknet From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 14:33:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BD6F1065696; Tue, 27 Oct 2009 14:33:22 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 407FD8FC20; Tue, 27 Oct 2009 14:33:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9REXMZf033708; Tue, 27 Oct 2009 14:33:22 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9REXMLx033707; Tue, 27 Oct 2009 14:33:22 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910271433.n9REXMLx033707@svn.freebsd.org> From: Andrew Gallatin Date: Tue, 27 Oct 2009 14:33:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198516 - in stable/7/sys: . contrib/pf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 14:33:22 -0000 Author: gallatin Date: Tue Oct 27 14:33:21 2009 New Revision: 198516 URL: http://svn.freebsd.org/changeset/base/198516 Log: MFC of r178332 - Unbreak firmware.ko build without kernel Actual patch was comitted in r198446; this just updates svn props Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 14:36:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABB6C106568F; Tue, 27 Oct 2009 14:36:37 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FB1B8FC27; Tue, 27 Oct 2009 14:36:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9REabiY033818; Tue, 27 Oct 2009 14:36:37 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9REabY7033817; Tue, 27 Oct 2009 14:36:37 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910271436.n9REabY7033817@svn.freebsd.org> From: Andrew Gallatin Date: Tue, 27 Oct 2009 14:36:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198517 - in stable/6/sys: . conf contrib/pf dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 14:36:37 -0000 Author: gallatin Date: Tue Oct 27 14:36:37 2009 New Revision: 198517 URL: http://svn.freebsd.org/changeset/base/198517 Log: MFC of r178332 - Unbreak firmware.ko build without kernel Actual patch was comitted in r198447; this just updates svn props Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 17:54:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0FE1106566B; Tue, 27 Oct 2009 17:54:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BFA298FC13; Tue, 27 Oct 2009 17:54:36 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 689E346B06; Tue, 27 Oct 2009 13:54:36 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id A37638A020; Tue, 27 Oct 2009 13:54:35 -0400 (EDT) From: John Baldwin To: pluknet Date: Tue, 27 Oct 2009 13:54:31 -0400 User-Agent: KMail/1.9.7 References: <200910261857.n9QIvvcZ000107@svn.freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200910271354.32185.jhb@freebsd.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 27 Oct 2009 13:54:35 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r198496 - in stable/7: etc etc/mtree include sys sys/contrib/pf sys/dev/mfi usr.sbin usr.sbin/acpi usr.sbin/adduser usr.sbin/arp usr.sbin/bluetooth usr.sbin/bluetooth/btpand usr.sbin/bl... X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 17:54:37 -0000 On Monday 26 October 2009 3:21:10 pm pluknet wrote: > 2009/10/26 John Baldwin : > > Author: jhb > > Date: Mon Oct 26 18:57:57 2009 > > New Revision: 198496 > > URL: http://svn.freebsd.org/changeset/base/198496 > > > > Log: > > =A0MFC 196200,196211,196280-196282: > > =A0Introduce mfiutil, a basic utility for managing LSI SAS-RAID & Dell= =20 PERC5/6 > > =A0controllers. =A0Controller, array, and drive status can be checked, = basic > > =A0attributes can be changed, and arrays and spares can be created and= =20 deleted. > > =A0Controller firmware can also be flashed. > > > > =A0This does not replace MegaCLI, found in ports, as that is officially= =20 sanctioned > > =A0and supported by LSI and includes vastly more functionality. =A0Howe= ver,=20 mfiutil > > =A0is open source and guaranteed to provide basic functionality, which = can=20 be > > =A0especially useful if you have a problem and can't get MegaCLI to wor= k. > > >=20 > John, thank you very much for mfc'ing those nice mfi- and mptutil! > It's interesting to know if this can be mfc'ed to 6 safely in principle, > without breaking some of existing interfaces. > I tried to use both on 6, and my experience was quite successful. They should both work fine on 6, though I do not have any plans to MFC them in FreeBSD itself. mfiutil has even been known to work on 4.x. :) Also, 8= =2E0=20 will ship before 7.3. :) =2D-=20 John Baldwin From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 18:30:26 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4E7B1065698; Tue, 27 Oct 2009 18:30:26 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C267D8FC2A; Tue, 27 Oct 2009 18:30:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9RIUQZK038782; Tue, 27 Oct 2009 18:30:26 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9RIUQHT038779; Tue, 27 Oct 2009 18:30:26 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910271830.n9RIUQHT038779@svn.freebsd.org> From: Andrew Gallatin Date: Tue, 27 Oct 2009 18:30:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198523 - in stable/7/sys: . contrib/pf dev/mxge X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 18:30:27 -0000 Author: gallatin Date: Tue Oct 27 18:30:26 2009 New Revision: 198523 URL: http://svn.freebsd.org/changeset/base/198523 Log: MFC: recent mxge watchdog improvements: 194909: add a dying flag (as a dependency) 198250: Move mxge(4)'s NIC watchdog reset handler to a taskqueue 198303: Check config space to react more quickly to failures Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/mxge/if_mxge.c stable/7/sys/dev/mxge/if_mxge_var.h Modified: stable/7/sys/dev/mxge/if_mxge.c ============================================================================== --- stable/7/sys/dev/mxge/if_mxge.c Tue Oct 27 18:17:07 2009 (r198522) +++ stable/7/sys/dev/mxge/if_mxge.c Tue Oct 27 18:30:26 2009 (r198523) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -3368,7 +3369,6 @@ mxge_open(mxge_softc_t *sc) } sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); return 0; @@ -3385,7 +3385,6 @@ mxge_close(mxge_softc_t *sc, int down) mxge_cmd_t cmd; int err, old_down_cnt; - callout_stop(&sc->co_hdl); sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; if (!down) { old_down_cnt = sc->down_cnt; @@ -3457,7 +3456,7 @@ mxge_read_reboot(mxge_softc_t *sc) return (pci_read_config(dev, vs + 0x14, 4)); } -static int +static void mxge_watchdog_reset(mxge_softc_t *sc) { struct pci_devinfo *dinfo; @@ -3488,7 +3487,6 @@ mxge_watchdog_reset(mxge_softc_t *sc) cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); if (cmd == 0xffff) { device_printf(sc->dev, "NIC disappeared!\n"); - return (err); } } if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) { @@ -3547,18 +3545,40 @@ mxge_watchdog_reset(mxge_softc_t *sc) } sc->watchdog_resets++; } else { - device_printf(sc->dev, "NIC did not reboot, ring state:\n"); - device_printf(sc->dev, "tx.req=%d tx.done=%d\n", - sc->ss->tx.req, sc->ss->tx.done); - device_printf(sc->dev, "pkt_done=%d fw=%d\n", - sc->ss->tx.pkt_done, - be32toh(sc->ss->fw_stats->send_done_count)); - device_printf(sc->dev, "not resetting\n"); + device_printf(sc->dev, + "NIC did not reboot, not resetting\n"); + err = 0; } - if (err) + if (err) { device_printf(sc->dev, "watchdog reset failed\n"); + } else { + if (sc->dying == 2) + sc->dying = 0; + callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); + } +} - return (err); +static void +mxge_watchdog_task(void *arg, int pending) +{ + mxge_softc_t *sc = arg; + + + mtx_lock(&sc->driver_mtx); + mxge_watchdog_reset(sc); + mtx_unlock(&sc->driver_mtx); +} + +static void +mxge_warn_stuck(mxge_softc_t *sc, mxge_tx_ring_t *tx, int slice) +{ + tx = &sc->ss[slice].tx; + device_printf(sc->dev, "slice %d struck? ring state:\n", slice); + device_printf(sc->dev, "tx.req=%d tx.done=%d\n", + tx->req, tx->done); + device_printf(sc->dev, "pkt_done=%d fw=%d\n", + tx->pkt_done, + be32toh(sc->ss->fw_stats->send_done_count)); } static int @@ -3574,11 +3594,14 @@ mxge_watchdog(mxge_softc_t *sc) tx->watchdog_req != tx->watchdog_done && tx->done == tx->watchdog_done) { /* check for pause blocking before resetting */ - if (tx->watchdog_rx_pause == rx_pause) - err = mxge_watchdog_reset(sc); - else + if (tx->watchdog_rx_pause == rx_pause) { + mxge_warn_stuck(sc, tx, 0); + taskqueue_enqueue(sc->tq, &sc->watchdog_task); + return (ENXIO); + } else { device_printf(sc->dev, "Flow control blocking " "xmits, check link partner\n"); + } } tx->watchdog_req = tx->req; @@ -3590,7 +3613,7 @@ mxge_watchdog(mxge_softc_t *sc) return (err); } -static void +static u_long mxge_update_stats(mxge_softc_t *sc) { struct mxge_slice_state *ss; @@ -3602,23 +3625,45 @@ mxge_update_stats(mxge_softc_t *sc) ipackets += ss->ipackets; } sc->ifp->if_ipackets = ipackets; - + return ipackets; } + static void mxge_tick(void *arg) { mxge_softc_t *sc = arg; + u_long pkts = 0; int err = 0; + int running, ticks; + uint16_t cmd; - /* aggregate stats from different slices */ - mxge_update_stats(sc); - if (!sc->watchdog_countdown) { - err = mxge_watchdog(sc); - sc->watchdog_countdown = 4; + ticks = mxge_ticks; + mtx_lock(&sc->driver_mtx); + running = sc->ifp->if_drv_flags & IFF_DRV_RUNNING; + mtx_unlock(&sc->driver_mtx); + if (running) { + /* aggregate stats from different slices */ + pkts = mxge_update_stats(sc); + if (!sc->watchdog_countdown) { + err = mxge_watchdog(sc); + sc->watchdog_countdown = 4; + } + sc->watchdog_countdown--; + } + if (pkts == 0) { + /* ensure NIC did not suffer h/w fault while idle */ + cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); + if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) { + sc->dying = 2; + taskqueue_enqueue(sc->tq, &sc->watchdog_task); + err = ENXIO; + } + /* look less often if NIC is idle */ + ticks *= 4; } - sc->watchdog_countdown--; + if (err == 0) - callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); + callout_reset(&sc->co_hdl, ticks, mxge_tick, sc); } @@ -3689,6 +3734,10 @@ mxge_ioctl(struct ifnet *ifp, u_long com case SIOCSIFFLAGS: mtx_lock(&sc->driver_mtx); + if (sc->dying) { + mtx_unlock(&sc->driver_mtx); + return EINVAL; + } if (ifp->if_flags & IFF_UP) { if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { err = mxge_open(sc); @@ -4211,6 +4260,17 @@ mxge_attach(device_t dev) sc->dev = dev; mxge_fetch_tunables(sc); + TASK_INIT(&sc->watchdog_task, 1, mxge_watchdog_task, sc); + sc->tq = taskqueue_create_fast("mxge_taskq", M_WAITOK, + taskqueue_thread_enqueue, + &sc->tq); + if (sc->tq == NULL) { + err = ENOMEM; + goto abort_with_nothing; + } + taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s taskq", + device_get_nameunit(sc->dev)); + err = bus_dma_tag_create(NULL, /* parent */ 1, /* alignment */ 0, /* boundary */ @@ -4227,7 +4287,7 @@ mxge_attach(device_t dev) if (err != 0) { device_printf(sc->dev, "Err %d allocating parent dmat\n", err); - goto abort_with_nothing; + goto abort_with_tq; } ifp = sc->ifp = if_alloc(IFT_ETHER); @@ -4354,12 +4414,14 @@ mxge_attach(device_t dev) mxge_media_status); mxge_set_media(sc, IFM_ETHER | IFM_AUTO); mxge_media_probe(sc); + sc->dying = 0; ether_ifattach(ifp, sc->mac_addr); /* ether_ifattach sets mtu to 1500 */ if (ifp->if_capabilities & IFCAP_JUMBO_MTU) ifp->if_mtu = 9000; mxge_add_sysctls(sc); + callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); return 0; abort_with_rings: @@ -4381,7 +4443,12 @@ abort_with_lock: if_free(ifp); abort_with_parent_dmat: bus_dma_tag_destroy(sc->parent_dmat); - +abort_with_tq: + if (sc->tq != NULL) { + taskqueue_drain(sc->tq, &sc->watchdog_task); + taskqueue_free(sc->tq); + sc->tq = NULL; + } abort_with_nothing: return err; } @@ -4397,10 +4464,16 @@ mxge_detach(device_t dev) return EBUSY; } mtx_lock(&sc->driver_mtx); + sc->dying = 1; if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) mxge_close(sc, 0); mtx_unlock(&sc->driver_mtx); ether_ifdetach(sc->ifp); + if (sc->tq != NULL) { + taskqueue_drain(sc->tq, &sc->watchdog_task); + taskqueue_free(sc->tq); + sc->tq = NULL; + } callout_drain(&sc->co_hdl); ifmedia_removeall(&sc->media); mxge_dummy_rdma(sc, 0); Modified: stable/7/sys/dev/mxge/if_mxge_var.h ============================================================================== --- stable/7/sys/dev/mxge/if_mxge_var.h Tue Oct 27 18:17:07 2009 (r198522) +++ stable/7/sys/dev/mxge/if_mxge_var.h Tue Oct 27 18:30:26 2009 (r198523) @@ -248,8 +248,11 @@ struct mxge_softc { int need_media_probe; int num_slices; int rx_ring_size; + int dying; mxge_dma_t dmabench_dma; struct callout co_hdl; + struct taskqueue *tq; + struct task watchdog_task; struct sysctl_oid *slice_sysctl_tree; struct sysctl_ctx_list slice_sysctl_ctx; char *mac_addr_string; From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 18:30:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A3CB10656AA; Tue, 27 Oct 2009 18:30:56 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 874B58FC34; Tue, 27 Oct 2009 18:30:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9RIUuOh038826; Tue, 27 Oct 2009 18:30:56 GMT (envelope-from gallatin@svn.freebsd.org) Received: (from gallatin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9RIUuWA038823; Tue, 27 Oct 2009 18:30:56 GMT (envelope-from gallatin@svn.freebsd.org) Message-Id: <200910271830.n9RIUuWA038823@svn.freebsd.org> From: Andrew Gallatin Date: Tue, 27 Oct 2009 18:30:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198524 - in stable/6/sys: . conf contrib/pf dev/cxgb dev/mxge X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 18:30:57 -0000 Author: gallatin Date: Tue Oct 27 18:30:56 2009 New Revision: 198524 URL: http://svn.freebsd.org/changeset/base/198524 Log: MFC: recent mxge watchdog improvements: 194909: add a dying flag (as a dependency) 198250: Move mxge(4)'s NIC watchdog reset handler to a taskqueue 198303: Check config space to react more quickly to failures Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/dev/mxge/if_mxge.c stable/6/sys/dev/mxge/if_mxge_var.h Modified: stable/6/sys/dev/mxge/if_mxge.c ============================================================================== --- stable/6/sys/dev/mxge/if_mxge.c Tue Oct 27 18:30:26 2009 (r198523) +++ stable/6/sys/dev/mxge/if_mxge.c Tue Oct 27 18:30:56 2009 (r198524) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -3368,7 +3369,6 @@ mxge_open(mxge_softc_t *sc) } sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); return 0; @@ -3385,15 +3385,13 @@ mxge_close(mxge_softc_t *sc, int down) mxge_cmd_t cmd; int err, old_down_cnt; - callout_stop(&sc->co_hdl); sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; if (!down) { old_down_cnt = sc->down_cnt; mb(); err = mxge_send_cmd(sc, MXGEFW_CMD_ETHERNET_DOWN, &cmd); if (err) { - device_printf(sc->dev, - "Couldn't bring down link\n"); + device_printf(sc->dev, "Couldn't bring down link\n"); } if (old_down_cnt == sc->down_cnt) { /* wait for down irq */ @@ -3458,7 +3456,7 @@ mxge_read_reboot(mxge_softc_t *sc) return (pci_read_config(dev, vs + 0x14, 4)); } -static int +static void mxge_watchdog_reset(mxge_softc_t *sc) { struct pci_devinfo *dinfo; @@ -3489,7 +3487,6 @@ mxge_watchdog_reset(mxge_softc_t *sc) cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); if (cmd == 0xffff) { device_printf(sc->dev, "NIC disappeared!\n"); - return (err); } } if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) { @@ -3548,18 +3545,40 @@ mxge_watchdog_reset(mxge_softc_t *sc) } sc->watchdog_resets++; } else { - device_printf(sc->dev, "NIC did not reboot, ring state:\n"); - device_printf(sc->dev, "tx.req=%d tx.done=%d\n", - sc->ss->tx.req, sc->ss->tx.done); - device_printf(sc->dev, "pkt_done=%d fw=%d\n", - sc->ss->tx.pkt_done, - be32toh(sc->ss->fw_stats->send_done_count)); - device_printf(sc->dev, "not resetting\n"); + device_printf(sc->dev, + "NIC did not reboot, not resetting\n"); + err = 0; } - if (err) + if (err) { device_printf(sc->dev, "watchdog reset failed\n"); + } else { + if (sc->dying == 2) + sc->dying = 0; + callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); + } +} - return (err); +static void +mxge_watchdog_task(void *arg, int pending) +{ + mxge_softc_t *sc = arg; + + + mtx_lock(&sc->driver_mtx); + mxge_watchdog_reset(sc); + mtx_unlock(&sc->driver_mtx); +} + +static void +mxge_warn_stuck(mxge_softc_t *sc, mxge_tx_ring_t *tx, int slice) +{ + tx = &sc->ss[slice].tx; + device_printf(sc->dev, "slice %d struck? ring state:\n", slice); + device_printf(sc->dev, "tx.req=%d tx.done=%d\n", + tx->req, tx->done); + device_printf(sc->dev, "pkt_done=%d fw=%d\n", + tx->pkt_done, + be32toh(sc->ss->fw_stats->send_done_count)); } static int @@ -3575,11 +3594,14 @@ mxge_watchdog(mxge_softc_t *sc) tx->watchdog_req != tx->watchdog_done && tx->done == tx->watchdog_done) { /* check for pause blocking before resetting */ - if (tx->watchdog_rx_pause == rx_pause) - err = mxge_watchdog_reset(sc); - else + if (tx->watchdog_rx_pause == rx_pause) { + mxge_warn_stuck(sc, tx, 0); + taskqueue_enqueue(sc->tq, &sc->watchdog_task); + return (ENXIO); + } else { device_printf(sc->dev, "Flow control blocking " "xmits, check link partner\n"); + } } tx->watchdog_req = tx->req; @@ -3591,7 +3613,7 @@ mxge_watchdog(mxge_softc_t *sc) return (err); } -static void +static u_long mxge_update_stats(mxge_softc_t *sc) { struct mxge_slice_state *ss; @@ -3603,23 +3625,45 @@ mxge_update_stats(mxge_softc_t *sc) ipackets += ss->ipackets; } sc->ifp->if_ipackets = ipackets; - + return ipackets; } + static void mxge_tick(void *arg) { mxge_softc_t *sc = arg; + u_long pkts = 0; int err = 0; + int running, ticks; + uint16_t cmd; - /* aggregate stats from different slices */ - mxge_update_stats(sc); - if (!sc->watchdog_countdown) { - err = mxge_watchdog(sc); - sc->watchdog_countdown = 4; + ticks = mxge_ticks; + mtx_lock(&sc->driver_mtx); + running = sc->ifp->if_drv_flags & IFF_DRV_RUNNING; + mtx_unlock(&sc->driver_mtx); + if (running) { + /* aggregate stats from different slices */ + pkts = mxge_update_stats(sc); + if (!sc->watchdog_countdown) { + err = mxge_watchdog(sc); + sc->watchdog_countdown = 4; + } + sc->watchdog_countdown--; + } + if (pkts == 0) { + /* ensure NIC did not suffer h/w fault while idle */ + cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); + if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) { + sc->dying = 2; + taskqueue_enqueue(sc->tq, &sc->watchdog_task); + err = ENXIO; + } + /* look less often if NIC is idle */ + ticks *= 4; } - sc->watchdog_countdown--; + if (err == 0) - callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); + callout_reset(&sc->co_hdl, ticks, mxge_tick, sc); } @@ -3690,6 +3734,10 @@ mxge_ioctl(struct ifnet *ifp, u_long com case SIOCSIFFLAGS: mtx_lock(&sc->driver_mtx); + if (sc->dying) { + mtx_unlock(&sc->driver_mtx); + return EINVAL; + } if (ifp->if_flags & IFF_UP) { if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { err = mxge_open(sc); @@ -4212,6 +4260,17 @@ mxge_attach(device_t dev) sc->dev = dev; mxge_fetch_tunables(sc); + TASK_INIT(&sc->watchdog_task, 1, mxge_watchdog_task, sc); + sc->tq = taskqueue_create_fast("mxge_taskq", M_WAITOK, + taskqueue_thread_enqueue, + &sc->tq); + if (sc->tq == NULL) { + err = ENOMEM; + goto abort_with_nothing; + } + taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s taskq", + device_get_nameunit(sc->dev)); + err = bus_dma_tag_create(NULL, /* parent */ 1, /* alignment */ 0, /* boundary */ @@ -4228,7 +4287,7 @@ mxge_attach(device_t dev) if (err != 0) { device_printf(sc->dev, "Err %d allocating parent dmat\n", err); - goto abort_with_nothing; + goto abort_with_tq; } ifp = sc->ifp = if_alloc(IFT_ETHER); @@ -4355,12 +4414,14 @@ mxge_attach(device_t dev) mxge_media_status); mxge_set_media(sc, IFM_ETHER | IFM_AUTO); mxge_media_probe(sc); + sc->dying = 0; ether_ifattach(ifp, sc->mac_addr); /* ether_ifattach sets mtu to 1500 */ if (ifp->if_capabilities & IFCAP_JUMBO_MTU) ifp->if_mtu = 9000; mxge_add_sysctls(sc); + callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); return 0; abort_with_rings: @@ -4382,7 +4443,12 @@ abort_with_lock: if_free(ifp); abort_with_parent_dmat: bus_dma_tag_destroy(sc->parent_dmat); - +abort_with_tq: + if (sc->tq != NULL) { + taskqueue_drain(sc->tq, &sc->watchdog_task); + taskqueue_free(sc->tq); + sc->tq = NULL; + } abort_with_nothing: return err; } @@ -4398,10 +4464,16 @@ mxge_detach(device_t dev) return EBUSY; } mtx_lock(&sc->driver_mtx); + sc->dying = 1; if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) mxge_close(sc, 0); mtx_unlock(&sc->driver_mtx); ether_ifdetach(sc->ifp); + if (sc->tq != NULL) { + taskqueue_drain(sc->tq, &sc->watchdog_task); + taskqueue_free(sc->tq); + sc->tq = NULL; + } callout_drain(&sc->co_hdl); ifmedia_removeall(&sc->media); mxge_dummy_rdma(sc, 0); Modified: stable/6/sys/dev/mxge/if_mxge_var.h ============================================================================== --- stable/6/sys/dev/mxge/if_mxge_var.h Tue Oct 27 18:30:26 2009 (r198523) +++ stable/6/sys/dev/mxge/if_mxge_var.h Tue Oct 27 18:30:56 2009 (r198524) @@ -247,8 +247,11 @@ struct mxge_softc { int need_media_probe; int num_slices; int rx_ring_size; + int dying; mxge_dma_t dmabench_dma; struct callout co_hdl; + struct taskqueue *tq; + struct task watchdog_task; struct sysctl_oid *slice_sysctl_tree; struct sysctl_ctx_list slice_sysctl_ctx; char *mac_addr_string; From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 21:02:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 031DD1065670; Tue, 27 Oct 2009 21:02:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC9188FC13; Tue, 27 Oct 2009 21:02:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9RL2g2N041923; Tue, 27 Oct 2009 21:02:42 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9RL2gWN041919; Tue, 27 Oct 2009 21:02:42 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910272102.n9RL2gWN041919@svn.freebsd.org> From: Ed Maste Date: Tue, 27 Oct 2009 21:02:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198528 - in stable/6/sys: . conf contrib/pf dev/aac dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 21:02:43 -0000 Author: emaste Date: Tue Oct 27 21:02:42 2009 New Revision: 198528 URL: http://svn.freebsd.org/changeset/base/198528 Log: MFC r188743,r188940 Use outbound message register 0 instead of mailbox 7 in aac_{rx,rkt}_get_fwstatus, as done in Adaptec's vendor driver as well as the Linux drivers. Submitted by: jkim, from Adaptec's driver == SVN rev 188743 modified aac_rx_get_fwstatus to use the AAC_RX_OMR0 register instead of AAC_RX_FWSTATUS, as that is the way it's done in Adaptec's vendor driver and in the Linux drivers. (The same applies to aac_rkt_get_fwstatus as well.) However, a concern has been raised about the compatibility of this change and old hardware / firmware versions. In the absense of specific information, revert to the original behaviour if the firmware does not support the "New comm." interface. Users of old cards or firmware haven't reported the problems that are potentially solved by switching to OMR0. Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/aac/aac.c stable/6/sys/dev/aac/aacreg.h stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/dev/aac/aac.c ============================================================================== --- stable/6/sys/dev/aac/aac.c Tue Oct 27 20:41:55 2009 (r198527) +++ stable/6/sys/dev/aac/aac.c Tue Oct 27 21:02:42 2009 (r198528) @@ -2373,7 +2373,8 @@ aac_rx_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_FWSTATUS)); + return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + AAC_RX_OMR0 : AAC_RX_FWSTATUS)); } static int @@ -2392,7 +2393,8 @@ aac_rkt_get_fwstatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_FWSTATUS)); + return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + AAC_RKT_OMR0 : AAC_RKT_FWSTATUS)); } /* Modified: stable/6/sys/dev/aac/aacreg.h ============================================================================== --- stable/6/sys/dev/aac/aacreg.h Tue Oct 27 20:41:55 2009 (r198527) +++ stable/6/sys/dev/aac/aacreg.h Tue Oct 27 21:02:42 2009 (r198528) @@ -1495,6 +1495,8 @@ enum { * and other related adapters. */ +#define AAC_RX_OMR0 0x18 /* outbound message register 0 */ +#define AAC_RX_OMR1 0x1c /* outbound message register 1 */ #define AAC_RX_IDBR 0x20 /* inbound doorbell register */ #define AAC_RX_IISR 0x24 /* inbound interrupt status register */ #define AAC_RX_IIMR 0x28 /* inbound interrupt mask register */ @@ -1512,6 +1514,8 @@ enum { * Unsurprisingly, it's quite similar to the i960! */ +#define AAC_RKT_OMR0 0x18 /* outbound message register 0 */ +#define AAC_RKT_OMR1 0x1c /* outbound message register 1 */ #define AAC_RKT_IDBR 0x20 /* inbound doorbell register */ #define AAC_RKT_IISR 0x24 /* inbound interrupt status register */ #define AAC_RKT_IIMR 0x28 /* inbound interrupt mask register */ From owner-svn-src-stable@FreeBSD.ORG Tue Oct 27 21:09:53 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FDA4106568D; Tue, 27 Oct 2009 21:09:53 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 145F68FC16; Tue, 27 Oct 2009 21:09:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9RL9q8m042091; Tue, 27 Oct 2009 21:09:52 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9RL9qSm042088; Tue, 27 Oct 2009 21:09:52 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910272109.n9RL9qSm042088@svn.freebsd.org> From: Ed Maste Date: Tue, 27 Oct 2009 21:09:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198529 - in stable/7/sys: . contrib/pf dev/aac X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 21:09:53 -0000 Author: emaste Date: Tue Oct 27 21:09:52 2009 New Revision: 198529 URL: http://svn.freebsd.org/changeset/base/198529 Log: MFC r188743,r188940 Use outbound message register 0 instead of mailbox 7 in aac_{rx,rkt}_get_fwstatus, as done in Adaptec's vendor driver as well as the Linux drivers. Submitted by: jkim, from Adaptec's driver == SVN rev 188743 modified aac_rx_get_fwstatus to use the AAC_RX_OMR0 register instead of AAC_RX_FWSTATUS, as that is the way it's done in Adaptec's vendor driver and in the Linux drivers. (The same applies to aac_rkt_get_fwstatus as well.) However, a concern has been raised about the compatibility of this change and old hardware / firmware versions. In the absense of specific information, revert to the original behaviour if the firmware does not support the "New comm." interface. Users of old cards or firmware haven't reported the problems that are potentially solved by switching to OMR0. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/aac/aac.c stable/7/sys/dev/aac/aacreg.h Modified: stable/7/sys/dev/aac/aac.c ============================================================================== --- stable/7/sys/dev/aac/aac.c Tue Oct 27 21:02:42 2009 (r198528) +++ stable/7/sys/dev/aac/aac.c Tue Oct 27 21:09:52 2009 (r198529) @@ -2375,7 +2375,8 @@ aac_rx_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_FWSTATUS)); + return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + AAC_RX_OMR0 : AAC_RX_FWSTATUS)); } static int @@ -2394,7 +2395,8 @@ aac_rkt_get_fwstatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_FWSTATUS)); + return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + AAC_RKT_OMR0 : AAC_RKT_FWSTATUS)); } /* Modified: stable/7/sys/dev/aac/aacreg.h ============================================================================== --- stable/7/sys/dev/aac/aacreg.h Tue Oct 27 21:02:42 2009 (r198528) +++ stable/7/sys/dev/aac/aacreg.h Tue Oct 27 21:09:52 2009 (r198529) @@ -1495,6 +1495,8 @@ enum { * and other related adapters. */ +#define AAC_RX_OMR0 0x18 /* outbound message register 0 */ +#define AAC_RX_OMR1 0x1c /* outbound message register 1 */ #define AAC_RX_IDBR 0x20 /* inbound doorbell register */ #define AAC_RX_IISR 0x24 /* inbound interrupt status register */ #define AAC_RX_IIMR 0x28 /* inbound interrupt mask register */ @@ -1512,6 +1514,8 @@ enum { * Unsurprisingly, it's quite similar to the i960! */ +#define AAC_RKT_OMR0 0x18 /* outbound message register 0 */ +#define AAC_RKT_OMR1 0x1c /* outbound message register 1 */ #define AAC_RKT_IDBR 0x20 /* inbound doorbell register */ #define AAC_RKT_IISR 0x24 /* inbound interrupt status register */ #define AAC_RKT_IIMR 0x28 /* inbound interrupt mask register */ From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 01:53:26 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B383106568F; Wed, 28 Oct 2009 01:53:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 18C928FC17; Wed, 28 Oct 2009 01:53:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9S1rPZj047293; Wed, 28 Oct 2009 01:53:25 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9S1rPN3047291; Wed, 28 Oct 2009 01:53:25 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910280153.n9S1rPN3047291@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 01:53:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198532 - in stable/6/sys: . conf contrib/pf dev/aac dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 01:53:26 -0000 Author: emaste Date: Wed Oct 28 01:53:25 2009 New Revision: 198532 URL: http://svn.freebsd.org/changeset/base/198532 Log: MFC r180072,182967 Add explicit PCI IDs for the following Adaptec RAID Series 2 adapters: Adaptec RAID 2045 Adaptec RAID 2405 Adaptec RAID 2445 Adaptec RAID 2805 Correct whitespace. Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/aac/aac_pci.c stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/dev/aac/aac_pci.c ============================================================================== --- stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 00:01:20 2009 (r198531) +++ stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 01:53:25 2009 (r198532) @@ -245,7 +245,15 @@ struct aac_ident {0x9005, 0x0285, 0x9005, 0x02d0, AAC_HWIF_I960RX, 0, "Adaptec RAID 52445"}, {0x9005, 0x0285, 0x9005, 0x02d1, AAC_HWIF_I960RX, 0, - "Adaptec RAID 5405"}, + "Adaptec RAID 5405"}, + {0x9005, 0x0285, 0x9005, 0x02d4, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2045"}, + {0x9005, 0x0285, 0x9005, 0x02d5, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2405"}, + {0x9005, 0x0285, 0x9005, 0x02d6, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2445"}, + {0x9005, 0x0285, 0x9005, 0x02d7, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2805"}, {0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0, "IBM ServeRAID-8k"}, {0x9005, 0x0285, 0x1014, 0x034d, AAC_HWIF_I960RX, 0, From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 02:20:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE05F106566B; Wed, 28 Oct 2009 02:20:29 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA4FA8FC22; Wed, 28 Oct 2009 02:20:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9S2KTqp047897; Wed, 28 Oct 2009 02:20:29 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9S2KTne047891; Wed, 28 Oct 2009 02:20:29 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910280220.n9S2KTne047891@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 02:20:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198533 - in stable/7/sys: . contrib/pf dev/aac X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 02:20:30 -0000 Author: emaste Date: Wed Oct 28 02:20:29 2009 New Revision: 198533 URL: http://svn.freebsd.org/changeset/base/198533 Log: MFC r188896 Sync with the official Adaptec vendor driver: [1] Add the support for the NARK controller which seems a variant of the i960Rx. [2] Split up memory regions and other resources in 2 different parts as long as NARK uses them separately (it is not clear to me why though as long as there are no more informations available on this controller). Please note that in all the other cases, the regions overlaps leaving the default behaviour for all the other controllers. [3] Implement a clock daemon responsible for maintain updated the wall clock time of the controller (run any 30 minutes). (Replace callout_schedule with callout_reset for [3].) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/aac/aac.c stable/7/sys/dev/aac/aac_debug.c stable/7/sys/dev/aac/aac_pci.c stable/7/sys/dev/aac/aacreg.h stable/7/sys/dev/aac/aacvar.h Modified: stable/7/sys/dev/aac/aac.c ============================================================================== --- stable/7/sys/dev/aac/aac.c Wed Oct 28 01:53:25 2009 (r198532) +++ stable/7/sys/dev/aac/aac.c Wed Oct 28 02:20:29 2009 (r198533) @@ -71,6 +71,7 @@ static void aac_startup(void *arg); static void aac_add_container(struct aac_softc *sc, struct aac_mntinforesp *mir, int f); static void aac_get_bus_info(struct aac_softc *sc); +static void aac_daemon(void *arg); /* Command Processing */ static void aac_timeout(struct aac_softc *sc); @@ -292,6 +293,9 @@ aac_attach(struct aac_softc *sc) TAILQ_INIT(&sc->aac_container_tqh); TAILQ_INIT(&sc->aac_ev_cmfree); + /* Initialize the clock daemon callout. */ + callout_init_mtx(&sc->aac_daemontime, &sc->aac_io_lock, 0); + /* * Initialize the adapter. */ @@ -349,9 +353,34 @@ aac_attach(struct aac_softc *sc) aac_get_bus_info(sc); } + mtx_lock(&sc->aac_io_lock); + callout_reset(&sc->aac_daemontime, 30 * 60 * hz, aac_daemon, sc); + mtx_unlock(&sc->aac_io_lock); + return(0); } +static void +aac_daemon(void *arg) +{ + struct timeval tv; + struct aac_softc *sc; + struct aac_fib *fib; + + sc = arg; + mtx_assert(&sc->aac_io_lock, MA_OWNED); + + if (callout_pending(&sc->aac_daemontime) || + callout_active(&sc->aac_daemontime) == 0) + return; + getmicrotime(&tv); + aac_alloc_sync_fib(sc, &fib); + *(uint32_t *)fib->data = tv.tv_sec; + aac_sync_fib(sc, SendHostTime, 0, fib, sizeof(uint32_t)); + aac_release_sync_fib(sc); + callout_reset(&sc->aac_daemontime, 30 * 60 * hz, aac_daemon, sc); +} + void aac_add_event(struct aac_softc *sc, struct aac_event *event) { @@ -632,9 +661,12 @@ aac_free(struct aac_softc *sc) bus_dma_tag_destroy(sc->aac_parent_dmat); /* release the register window mapping */ - if (sc->aac_regs_resource != NULL) + if (sc->aac_regs_res0 != NULL) + bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, + sc->aac_regs_rid0, sc->aac_regs_res0); + if (sc->aac_hwif == AAC_HWIF_NARK && sc->aac_regs_res1 != NULL) bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, - sc->aac_regs_rid, sc->aac_regs_resource); + sc->aac_regs_rid1, sc->aac_regs_res1); } /* @@ -654,6 +686,8 @@ aac_detach(device_t dev) if (sc->aac_state & AAC_STATE_OPEN) return(EBUSY); + callout_drain(&sc->aac_daemontime); + /* Remove the child containers */ while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) { error = device_delete_child(dev, co->co_disk); @@ -834,7 +868,7 @@ aac_new_intr(void *arg) } index &= ~2; for (i = 0; i < sizeof(struct aac_fib)/4; ++i) - ((u_int32_t *)fib)[i] = AAC_GETREG4(sc, index + i*4); + ((u_int32_t *)fib)[i] = AAC_MEM1_GETREG4(sc, index + i*4); aac_handle_aif(sc, fib); free(fib, M_AACBUF); @@ -1754,26 +1788,33 @@ aac_check_firmware(struct aac_softc *sc) /* Remap mem. resource, if required */ if ((sc->flags & AAC_FLAGS_NEW_COMM) && - atu_size > rman_get_size(sc->aac_regs_resource)) { + atu_size > rman_get_size(sc->aac_regs_res1)) { bus_release_resource( sc->aac_dev, SYS_RES_MEMORY, - sc->aac_regs_rid, sc->aac_regs_resource); - sc->aac_regs_resource = bus_alloc_resource( - sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid, + sc->aac_regs_rid1, sc->aac_regs_res1); + sc->aac_regs_res1 = bus_alloc_resource( + sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid1, 0ul, ~0ul, atu_size, RF_ACTIVE); - if (sc->aac_regs_resource == NULL) { - sc->aac_regs_resource = bus_alloc_resource_any( + if (sc->aac_regs_res1 == NULL) { + sc->aac_regs_res1 = bus_alloc_resource_any( sc->aac_dev, SYS_RES_MEMORY, - &sc->aac_regs_rid, RF_ACTIVE); - if (sc->aac_regs_resource == NULL) { + &sc->aac_regs_rid1, RF_ACTIVE); + if (sc->aac_regs_res1 == NULL) { device_printf(sc->aac_dev, "couldn't allocate register window\n"); return (ENXIO); } sc->flags &= ~AAC_FLAGS_NEW_COMM; } - sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); - sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); + sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1); + sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1); + + if (sc->aac_hwif == AAC_HWIF_NARK) { + sc->aac_regs_res0 = sc->aac_regs_res1; + sc->aac_regs_rid0 = sc->aac_regs_rid1; + sc->aac_btag0 = sc->aac_btag1; + sc->aac_bhandle0 = sc->aac_bhandle1; + } } /* Read preferred settings */ @@ -1944,10 +1985,10 @@ aac_init(struct aac_softc *sc) */ switch (sc->aac_hwif) { case AAC_HWIF_I960RX: - AAC_SETREG4(sc, AAC_RX_ODBR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, ~0); break; case AAC_HWIF_RKT: - AAC_SETREG4(sc, AAC_RKT_ODBR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, ~0); break; default: break; @@ -2367,7 +2408,7 @@ aac_sa_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_SA_FWSTATUS)); + return(AAC_MEM0_GETREG4(sc, AAC_SA_FWSTATUS)); } static int @@ -2375,7 +2416,7 @@ aac_rx_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? AAC_RX_OMR0 : AAC_RX_FWSTATUS)); } @@ -2386,7 +2427,7 @@ aac_fa_get_fwstatus(struct aac_softc *sc fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG4(sc, AAC_FA_FWSTATUS); + val = AAC_MEM0_GETREG4(sc, AAC_FA_FWSTATUS); return (val); } @@ -2395,7 +2436,7 @@ aac_rkt_get_fwstatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? AAC_RKT_OMR0 : AAC_RKT_FWSTATUS)); } @@ -2408,7 +2449,7 @@ aac_sa_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); + AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); } static void @@ -2416,7 +2457,7 @@ aac_rx_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_IDBR, qbit); + AAC_MEM0_SETREG4(sc, AAC_RX_IDBR, qbit); } static void @@ -2424,7 +2465,7 @@ aac_fa_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_FA_DOORBELL1, qbit); + AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL1, qbit); AAC_FA_HACK(sc); } @@ -2433,7 +2474,7 @@ aac_rkt_qnotify(struct aac_softc *sc, in { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_IDBR, qbit); + AAC_MEM0_SETREG4(sc, AAC_RKT_IDBR, qbit); } /* @@ -2444,7 +2485,7 @@ aac_sa_get_istatus(struct aac_softc *sc) { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG2(sc, AAC_SA_DOORBELL0)); + return(AAC_MEM0_GETREG2(sc, AAC_SA_DOORBELL0)); } static int @@ -2452,7 +2493,7 @@ aac_rx_get_istatus(struct aac_softc *sc) { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_ODBR)); + return(AAC_MEM0_GETREG4(sc, AAC_RX_ODBR)); } static int @@ -2462,7 +2503,7 @@ aac_fa_get_istatus(struct aac_softc *sc) fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG2(sc, AAC_FA_DOORBELL0); + val = AAC_MEM0_GETREG2(sc, AAC_FA_DOORBELL0); return (val); } @@ -2471,7 +2512,7 @@ aac_rkt_get_istatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_ODBR)); + return(AAC_MEM0_GETREG4(sc, AAC_RKT_ODBR)); } /* @@ -2482,7 +2523,7 @@ aac_sa_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); + AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); } static void @@ -2490,7 +2531,7 @@ aac_rx_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_ODBR, mask); + AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, mask); } static void @@ -2498,7 +2539,7 @@ aac_fa_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask); + AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask); AAC_FA_HACK(sc); } @@ -2507,7 +2548,7 @@ aac_rkt_clear_istatus(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_ODBR, mask); + AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, mask); } /* @@ -2519,11 +2560,11 @@ aac_sa_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_SA_MAILBOX, command); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); } static void @@ -2532,11 +2573,11 @@ aac_rx_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_MAILBOX, command); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); } static void @@ -2545,15 +2586,15 @@ aac_fa_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_FA_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX, command); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3); AAC_FA_HACK(sc); } @@ -2563,11 +2604,11 @@ aac_rkt_set_mailbox(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_MAILBOX, command); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3); } /* @@ -2578,7 +2619,7 @@ aac_sa_get_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4))); } static int @@ -2586,7 +2627,7 @@ aac_rx_get_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4))); } static int @@ -2596,7 +2637,7 @@ aac_fa_get_mailbox(struct aac_softc *sc, fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4)); + val = AAC_MEM1_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4)); return (val); } @@ -2605,7 +2646,7 @@ aac_rkt_get_mailbox(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4))); } /* @@ -2617,9 +2658,9 @@ aac_sa_set_interrupts(struct aac_softc * fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis"); if (enable) { - AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); } else { - AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0); + AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_SET, ~0); } } @@ -2630,11 +2671,11 @@ aac_rx_set_interrupts(struct aac_softc * if (enable) { if (sc->flags & AAC_FLAGS_NEW_COMM) - AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM); else - AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); } else { - AAC_SETREG4(sc, AAC_RX_OIMR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~0); } } @@ -2644,10 +2685,10 @@ aac_fa_set_interrupts(struct aac_softc * fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis"); if (enable) { - AAC_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS); AAC_FA_HACK(sc); } else { - AAC_SETREG2((sc), AAC_FA_MASK0, ~0); + AAC_MEM0_SETREG2((sc), AAC_FA_MASK0, ~0); AAC_FA_HACK(sc); } } @@ -2659,11 +2700,11 @@ aac_rkt_set_interrupts(struct aac_softc if (enable) { if (sc->flags & AAC_FLAGS_NEW_COMM) - AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM); else - AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS); } else { - AAC_SETREG4(sc, AAC_RKT_OIMR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~0); } } @@ -2677,19 +2718,19 @@ aac_rx_send_command(struct aac_softc *sc fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)"); - index = AAC_GETREG4(sc, AAC_RX_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE); if (index == 0xffffffffL) - index = AAC_GETREG4(sc, AAC_RX_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE); if (index == 0xffffffffL) return index; aac_enqueue_busy(cm); device = index; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); device += 4; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); device += 4; - AAC_SETREG4(sc, device, cm->cm_fib->Header.Size); - AAC_SETREG4(sc, AAC_RX_IQUE, index); + AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size); + AAC_MEM0_SETREG4(sc, AAC_RX_IQUE, index); return 0; } @@ -2700,19 +2741,19 @@ aac_rkt_send_command(struct aac_softc *s fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)"); - index = AAC_GETREG4(sc, AAC_RKT_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE); if (index == 0xffffffffL) - index = AAC_GETREG4(sc, AAC_RKT_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE); if (index == 0xffffffffL) return index; aac_enqueue_busy(cm); device = index; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); device += 4; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); device += 4; - AAC_SETREG4(sc, device, cm->cm_fib->Header.Size); - AAC_SETREG4(sc, AAC_RKT_IQUE, index); + AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size); + AAC_MEM0_SETREG4(sc, AAC_RKT_IQUE, index); return 0; } @@ -2724,7 +2765,7 @@ aac_rx_get_outb_queue(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_OQUE)); + return(AAC_MEM0_GETREG4(sc, AAC_RX_OQUE)); } static int @@ -2732,7 +2773,7 @@ aac_rkt_get_outb_queue(struct aac_softc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_OQUE)); + return(AAC_MEM0_GETREG4(sc, AAC_RKT_OQUE)); } static void @@ -2740,7 +2781,7 @@ aac_rx_set_outb_queue(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_OQUE, index); + AAC_MEM0_SETREG4(sc, AAC_RX_OQUE, index); } static void @@ -2748,7 +2789,7 @@ aac_rkt_set_outb_queue(struct aac_softc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_OQUE, index); + AAC_MEM0_SETREG4(sc, AAC_RKT_OQUE, index); } /* Modified: stable/7/sys/dev/aac/aac_debug.c ============================================================================== --- stable/7/sys/dev/aac/aac_debug.c Wed Oct 28 01:53:25 2009 (r198532) +++ stable/7/sys/dev/aac/aac_debug.c Wed Oct 28 02:20:29 2009 (r198533) @@ -134,17 +134,18 @@ aac_printstate0(void) aac_print_queues(sc); switch (sc->aac_hwif) { case AAC_HWIF_I960RX: + case AAC_HWIF_NARK: device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x " - "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR), - AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR)); + "IISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_IDBR), + AAC_MEM0_GETREG4(sc, AAC_RX_IIMR), AAC_MEM0_GETREG4(sc, AAC_RX_IISR)); device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " - "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), - AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); - AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | + "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR), + AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR)); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/); device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " - "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), - AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); + "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR), + AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR)); break; case AAC_HWIF_STRONGARM: /* XXX implement */ Modified: stable/7/sys/dev/aac/aac_pci.c ============================================================================== --- stable/7/sys/dev/aac/aac_pci.c Wed Oct 28 01:53:25 2009 (r198532) +++ stable/7/sys/dev/aac/aac_pci.c Wed Oct 28 02:20:29 2009 (r198533) @@ -374,21 +374,32 @@ aac_pci_attach(device_t dev) /* * Allocate the PCI register window. */ - sc->aac_regs_rid = PCIR_BAR(0); - if ((sc->aac_regs_resource = bus_alloc_resource_any(sc->aac_dev, - SYS_RES_MEMORY, - &sc->aac_regs_rid, - RF_ACTIVE)) == - NULL) { + sc->aac_regs_rid0 = PCIR_BAR(0); + if ((sc->aac_regs_res0 = bus_alloc_resource_any(sc->aac_dev, + SYS_RES_MEMORY, &sc->aac_regs_rid0, RF_ACTIVE)) == NULL) { device_printf(sc->aac_dev, - "couldn't allocate register window\n"); + "couldn't allocate register window 0\n"); goto out; } - sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); - sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); + sc->aac_btag0 = rman_get_bustag(sc->aac_regs_res0); + sc->aac_bhandle0 = rman_get_bushandle(sc->aac_regs_res0); - /* assume failure is 'out of memory' */ - error = ENOMEM; + if (sc->aac_hwif == AAC_HWIF_NARK) { + sc->aac_regs_rid1 = PCIR_BAR(1); + if ((sc->aac_regs_res1 = bus_alloc_resource_any(sc->aac_dev, + SYS_RES_MEMORY, &sc->aac_regs_rid1, RF_ACTIVE)) == NULL) { + device_printf(sc->aac_dev, + "couldn't allocate register window 1\n"); + goto out; + } + sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1); + sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1); + } else { + sc->aac_regs_res1 = sc->aac_regs_res0; + sc->aac_regs_rid1 = sc->aac_regs_rid0; + sc->aac_btag1 = sc->aac_btag0; + sc->aac_bhandle1 = sc->aac_bhandle0; + } /* * Allocate the parent bus DMA tag appropriate for our PCI interface. @@ -418,7 +429,8 @@ aac_pci_attach(device_t dev) sc->aac_hwif = id->hwif; switch(sc->aac_hwif) { case AAC_HWIF_I960RX: - fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx"); + case AAC_HWIF_NARK: + fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx/NARK"); sc->aac_if = aac_rx_interface; break; case AAC_HWIF_STRONGARM: Modified: stable/7/sys/dev/aac/aacreg.h ============================================================================== --- stable/7/sys/dev/aac/aacreg.h Wed Oct 28 01:53:25 2009 (r198532) +++ stable/7/sys/dev/aac/aacreg.h Wed Oct 28 02:20:29 2009 (r198533) @@ -1468,7 +1468,7 @@ enum { #define AAC_FA_FWSTATUS 0x2c /* Mailbox 7 */ #define AAC_FA_INTSRC 0x900 -#define AAC_FA_HACK(sc) (void)AAC_GETREG4(sc, AAC_FA_INTSRC) +#define AAC_FA_HACK(sc) (void)AAC_MEM0_GETREG4(sc, AAC_FA_INTSRC) /* * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based Modified: stable/7/sys/dev/aac/aacvar.h ============================================================================== --- stable/7/sys/dev/aac/aacvar.h Wed Oct 28 01:53:25 2009 (r198532) +++ stable/7/sys/dev/aac/aacvar.h Wed Oct 28 02:20:29 2009 (r198533) @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -259,18 +260,31 @@ extern struct aac_interface aac_rkt_inte #define AAC_GET_OUTB_QUEUE(sc) ((sc)->aac_if.aif_get_outb_queue((sc))) #define AAC_SET_OUTB_QUEUE(sc, idx) ((sc)->aac_if.aif_set_outb_queue((sc), (idx))) -#define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \ - sc->aac_bhandle, reg) -#define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \ - sc->aac_bhandle, reg) -#define AAC_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG1(sc, reg) bus_space_read_1 (sc->aac_btag, \ - sc->aac_bhandle, reg) +#define AAC_MEM0_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag0, \ + sc->aac_bhandle0, reg) +#define AAC_MEM0_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag0, \ + sc->aac_bhandle0, reg) +#define AAC_MEM0_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag0, \ + sc->aac_bhandle0, reg) + +#define AAC_MEM1_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag1, \ + sc->aac_bhandle1, reg) +#define AAC_MEM1_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag1, \ + sc->aac_bhandle1, reg) +#define AAC_MEM1_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag1, \ + sc->aac_bhandle1, reg) /* fib context (IOCTL) */ struct aac_fib_context { @@ -287,11 +301,10 @@ struct aac_softc { /* bus connections */ device_t aac_dev; - struct resource *aac_regs_resource; /* register interface - * window */ - int aac_regs_rid; /* resource ID */ - bus_space_handle_t aac_bhandle; /* bus space handle */ - bus_space_tag_t aac_btag; /* bus space tag */ + struct resource *aac_regs_res0, *aac_regs_res1; /* reg. if. window */ + int aac_regs_rid0, aac_regs_rid1; /* resource ID */ + bus_space_handle_t aac_bhandle0, aac_bhandle1; /* bus space handle */ + bus_space_tag_t aac_btag0, aac_btag1; /* bus space tag */ bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ bus_dma_tag_t aac_buffer_dmat; /* data buffer/command * DMA tag */ @@ -315,6 +328,7 @@ struct aac_softc #define AAC_HWIF_STRONGARM 1 #define AAC_HWIF_FALCON 2 #define AAC_HWIF_RKT 3 +#define AAC_HWIF_NARK 4 #define AAC_HWIF_UNKNOWN -1 bus_dma_tag_t aac_common_dmat; /* common structure * DMA tag */ @@ -398,6 +412,8 @@ struct aac_softc u_int32_t scsi_method_id; TAILQ_HEAD(,aac_sim) aac_sim_tqh; + struct callout aac_daemontime; /* clock daemon callout */ + u_int32_t aac_max_fibs; /* max. FIB count */ u_int32_t aac_max_fibs_alloc; /* max. alloc. per alloc_commands() */ u_int32_t aac_max_fib_size; /* max. FIB size */ From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 13:38:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A579106568D; Wed, 28 Oct 2009 13:38:07 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6672B8FC20; Wed, 28 Oct 2009 13:38:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SDc7Up062773; Wed, 28 Oct 2009 13:38:07 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SDc7MU062767; Wed, 28 Oct 2009 13:38:07 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910281338.n9SDc7MU062767@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 13:38:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198540 - in stable/6/sys: . conf contrib/pf dev/aac dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 13:38:07 -0000 Author: emaste Date: Wed Oct 28 13:38:07 2009 New Revision: 198540 URL: http://svn.freebsd.org/changeset/base/198540 Log: MFC r188896 Sync with the official Adaptec vendor driver: [1] Add the support for the NARK controller which seems a variant of the i960Rx. [2] Split up memory regions and other resources in 2 different parts as long as NARK uses them separately (it is not clear to me why though as long as there are no more informations available on this controller). Please note that in all the other cases, the regions overlaps leaving the default behaviour for all the other controllers. [3] Implement a clock daemon responsible for maintain updated the wall clock time of the controller (run any 30 minutes). (Replace callout_schedule with callout_reset for [3].) Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/aac/aac.c stable/6/sys/dev/aac/aac_debug.c stable/6/sys/dev/aac/aac_pci.c stable/6/sys/dev/aac/aacreg.h stable/6/sys/dev/aac/aacvar.h stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/dev/aac/aac.c ============================================================================== --- stable/6/sys/dev/aac/aac.c Wed Oct 28 12:10:29 2009 (r198539) +++ stable/6/sys/dev/aac/aac.c Wed Oct 28 13:38:07 2009 (r198540) @@ -71,6 +71,7 @@ static void aac_startup(void *arg); static void aac_add_container(struct aac_softc *sc, struct aac_mntinforesp *mir, int f); static void aac_get_bus_info(struct aac_softc *sc); +static void aac_daemon(void *arg); /* Command Processing */ static void aac_timeout(struct aac_softc *sc); @@ -292,6 +293,9 @@ aac_attach(struct aac_softc *sc) TAILQ_INIT(&sc->aac_container_tqh); TAILQ_INIT(&sc->aac_ev_cmfree); + /* Initialize the clock daemon callout. */ + callout_init_mtx(&sc->aac_daemontime, &sc->aac_io_lock, 0); + /* * Initialize the adapter. */ @@ -349,9 +353,34 @@ aac_attach(struct aac_softc *sc) aac_get_bus_info(sc); } + mtx_lock(&sc->aac_io_lock); + callout_reset(&sc->aac_daemontime, 30 * 60 * hz, aac_daemon, sc); + mtx_unlock(&sc->aac_io_lock); + return(0); } +static void +aac_daemon(void *arg) +{ + struct timeval tv; + struct aac_softc *sc; + struct aac_fib *fib; + + sc = arg; + mtx_assert(&sc->aac_io_lock, MA_OWNED); + + if (callout_pending(&sc->aac_daemontime) || + callout_active(&sc->aac_daemontime) == 0) + return; + getmicrotime(&tv); + aac_alloc_sync_fib(sc, &fib); + *(uint32_t *)fib->data = tv.tv_sec; + aac_sync_fib(sc, SendHostTime, 0, fib, sizeof(uint32_t)); + aac_release_sync_fib(sc); + callout_schedule(&sc->aac_daemontime, 30 * 60 * hz); +} + void aac_add_event(struct aac_softc *sc, struct aac_event *event) { @@ -632,9 +661,12 @@ aac_free(struct aac_softc *sc) bus_dma_tag_destroy(sc->aac_parent_dmat); /* release the register window mapping */ - if (sc->aac_regs_resource != NULL) + if (sc->aac_regs_res0 != NULL) + bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, + sc->aac_regs_rid0, sc->aac_regs_res0); + if (sc->aac_hwif == AAC_HWIF_NARK && sc->aac_regs_res1 != NULL) bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, - sc->aac_regs_rid, sc->aac_regs_resource); + sc->aac_regs_rid1, sc->aac_regs_res1); } /* @@ -654,6 +686,8 @@ aac_detach(device_t dev) if (sc->aac_state & AAC_STATE_OPEN) return(EBUSY); + callout_drain(&sc->aac_daemontime); + /* Remove the child containers */ while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) { error = device_delete_child(dev, co->co_disk); @@ -834,7 +868,7 @@ aac_new_intr(void *arg) } index &= ~2; for (i = 0; i < sizeof(struct aac_fib)/4; ++i) - ((u_int32_t *)fib)[i] = AAC_GETREG4(sc, index + i*4); + ((u_int32_t *)fib)[i] = AAC_MEM1_GETREG4(sc, index + i*4); aac_handle_aif(sc, fib); free(fib, M_AACBUF); @@ -1753,26 +1787,33 @@ aac_check_firmware(struct aac_softc *sc) /* Remap mem. resource, if required */ if ((sc->flags & AAC_FLAGS_NEW_COMM) && - atu_size > rman_get_size(sc->aac_regs_resource)) { + atu_size > rman_get_size(sc->aac_regs_res1)) { bus_release_resource( sc->aac_dev, SYS_RES_MEMORY, - sc->aac_regs_rid, sc->aac_regs_resource); - sc->aac_regs_resource = bus_alloc_resource( - sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid, + sc->aac_regs_rid1, sc->aac_regs_res1); + sc->aac_regs_res1 = bus_alloc_resource( + sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid1, 0ul, ~0ul, atu_size, RF_ACTIVE); - if (sc->aac_regs_resource == NULL) { - sc->aac_regs_resource = bus_alloc_resource_any( + if (sc->aac_regs_res1 == NULL) { + sc->aac_regs_res1 = bus_alloc_resource_any( sc->aac_dev, SYS_RES_MEMORY, - &sc->aac_regs_rid, RF_ACTIVE); - if (sc->aac_regs_resource == NULL) { + &sc->aac_regs_rid1, RF_ACTIVE); + if (sc->aac_regs_res1 == NULL) { device_printf(sc->aac_dev, "couldn't allocate register window\n"); return (ENXIO); } sc->flags &= ~AAC_FLAGS_NEW_COMM; } - sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); - sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); + sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1); + sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1); + + if (sc->aac_hwif == AAC_HWIF_NARK) { + sc->aac_regs_res0 = sc->aac_regs_res1; + sc->aac_regs_rid0 = sc->aac_regs_rid1; + sc->aac_btag0 = sc->aac_btag1; + sc->aac_bhandle0 = sc->aac_bhandle1; + } } /* Read preferred settings */ @@ -1943,10 +1984,10 @@ aac_init(struct aac_softc *sc) */ switch (sc->aac_hwif) { case AAC_HWIF_I960RX: - AAC_SETREG4(sc, AAC_RX_ODBR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, ~0); break; case AAC_HWIF_RKT: - AAC_SETREG4(sc, AAC_RKT_ODBR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, ~0); break; default: break; @@ -2365,7 +2406,7 @@ aac_sa_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_SA_FWSTATUS)); + return(AAC_MEM0_GETREG4(sc, AAC_SA_FWSTATUS)); } static int @@ -2373,7 +2414,7 @@ aac_rx_get_fwstatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? AAC_RX_OMR0 : AAC_RX_FWSTATUS)); } @@ -2384,7 +2425,7 @@ aac_fa_get_fwstatus(struct aac_softc *sc fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG4(sc, AAC_FA_FWSTATUS); + val = AAC_MEM0_GETREG4(sc, AAC_FA_FWSTATUS); return (val); } @@ -2393,7 +2434,7 @@ aac_rkt_get_fwstatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? + return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ? AAC_RKT_OMR0 : AAC_RKT_FWSTATUS)); } @@ -2406,7 +2447,7 @@ aac_sa_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); + AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); } static void @@ -2414,7 +2455,7 @@ aac_rx_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_IDBR, qbit); + AAC_MEM0_SETREG4(sc, AAC_RX_IDBR, qbit); } static void @@ -2422,7 +2463,7 @@ aac_fa_qnotify(struct aac_softc *sc, int { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_FA_DOORBELL1, qbit); + AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL1, qbit); AAC_FA_HACK(sc); } @@ -2431,7 +2472,7 @@ aac_rkt_qnotify(struct aac_softc *sc, in { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_IDBR, qbit); + AAC_MEM0_SETREG4(sc, AAC_RKT_IDBR, qbit); } /* @@ -2442,7 +2483,7 @@ aac_sa_get_istatus(struct aac_softc *sc) { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG2(sc, AAC_SA_DOORBELL0)); + return(AAC_MEM0_GETREG2(sc, AAC_SA_DOORBELL0)); } static int @@ -2450,7 +2491,7 @@ aac_rx_get_istatus(struct aac_softc *sc) { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_ODBR)); + return(AAC_MEM0_GETREG4(sc, AAC_RX_ODBR)); } static int @@ -2460,7 +2501,7 @@ aac_fa_get_istatus(struct aac_softc *sc) fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG2(sc, AAC_FA_DOORBELL0); + val = AAC_MEM0_GETREG2(sc, AAC_FA_DOORBELL0); return (val); } @@ -2469,7 +2510,7 @@ aac_rkt_get_istatus(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_ODBR)); + return(AAC_MEM0_GETREG4(sc, AAC_RKT_ODBR)); } /* @@ -2480,7 +2521,7 @@ aac_sa_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); + AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); } static void @@ -2488,7 +2529,7 @@ aac_rx_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_ODBR, mask); + AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, mask); } static void @@ -2496,7 +2537,7 @@ aac_fa_clear_istatus(struct aac_softc *s { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask); + AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask); AAC_FA_HACK(sc); } @@ -2505,7 +2546,7 @@ aac_rkt_clear_istatus(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_ODBR, mask); + AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, mask); } /* @@ -2517,11 +2558,11 @@ aac_sa_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_SA_MAILBOX, command); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); } static void @@ -2530,11 +2571,11 @@ aac_rx_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_MAILBOX, command); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); } static void @@ -2543,15 +2584,15 @@ aac_fa_set_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_FA_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX, command); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2); AAC_FA_HACK(sc); - AAC_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3); AAC_FA_HACK(sc); } @@ -2561,11 +2602,11 @@ aac_rkt_set_mailbox(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_MAILBOX, command); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX, command); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2); + AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3); } /* @@ -2576,7 +2617,7 @@ aac_sa_get_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4))); } static int @@ -2584,7 +2625,7 @@ aac_rx_get_mailbox(struct aac_softc *sc, { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4))); } static int @@ -2594,7 +2635,7 @@ aac_fa_get_mailbox(struct aac_softc *sc, fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - val = AAC_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4)); + val = AAC_MEM1_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4)); return (val); } @@ -2603,7 +2644,7 @@ aac_rkt_get_mailbox(struct aac_softc *sc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4))); + return(AAC_MEM1_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4))); } /* @@ -2615,9 +2656,9 @@ aac_sa_set_interrupts(struct aac_softc * fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis"); if (enable) { - AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); } else { - AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0); + AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_SET, ~0); } } @@ -2628,11 +2669,11 @@ aac_rx_set_interrupts(struct aac_softc * if (enable) { if (sc->flags & AAC_FLAGS_NEW_COMM) - AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM); else - AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); } else { - AAC_SETREG4(sc, AAC_RX_OIMR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~0); } } @@ -2642,10 +2683,10 @@ aac_fa_set_interrupts(struct aac_softc * fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis"); if (enable) { - AAC_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS); AAC_FA_HACK(sc); } else { - AAC_SETREG2((sc), AAC_FA_MASK0, ~0); + AAC_MEM0_SETREG2((sc), AAC_FA_MASK0, ~0); AAC_FA_HACK(sc); } } @@ -2657,11 +2698,11 @@ aac_rkt_set_interrupts(struct aac_softc if (enable) { if (sc->flags & AAC_FLAGS_NEW_COMM) - AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM); else - AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS); } else { - AAC_SETREG4(sc, AAC_RKT_OIMR, ~0); + AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~0); } } @@ -2675,19 +2716,19 @@ aac_rx_send_command(struct aac_softc *sc fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)"); - index = AAC_GETREG4(sc, AAC_RX_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE); if (index == 0xffffffffL) - index = AAC_GETREG4(sc, AAC_RX_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE); if (index == 0xffffffffL) return index; aac_enqueue_busy(cm); device = index; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); device += 4; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); device += 4; - AAC_SETREG4(sc, device, cm->cm_fib->Header.Size); - AAC_SETREG4(sc, AAC_RX_IQUE, index); + AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size); + AAC_MEM0_SETREG4(sc, AAC_RX_IQUE, index); return 0; } @@ -2698,19 +2739,19 @@ aac_rkt_send_command(struct aac_softc *s fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)"); - index = AAC_GETREG4(sc, AAC_RKT_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE); if (index == 0xffffffffL) - index = AAC_GETREG4(sc, AAC_RKT_IQUE); + index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE); if (index == 0xffffffffL) return index; aac_enqueue_busy(cm); device = index; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL)); device += 4; - AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); + AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32)); device += 4; - AAC_SETREG4(sc, device, cm->cm_fib->Header.Size); - AAC_SETREG4(sc, AAC_RKT_IQUE, index); + AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size); + AAC_MEM0_SETREG4(sc, AAC_RKT_IQUE, index); return 0; } @@ -2722,7 +2763,7 @@ aac_rx_get_outb_queue(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RX_OQUE)); + return(AAC_MEM0_GETREG4(sc, AAC_RX_OQUE)); } static int @@ -2730,7 +2771,7 @@ aac_rkt_get_outb_queue(struct aac_softc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - return(AAC_GETREG4(sc, AAC_RKT_OQUE)); + return(AAC_MEM0_GETREG4(sc, AAC_RKT_OQUE)); } static void @@ -2738,7 +2779,7 @@ aac_rx_set_outb_queue(struct aac_softc * { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RX_OQUE, index); + AAC_MEM0_SETREG4(sc, AAC_RX_OQUE, index); } static void @@ -2746,7 +2787,7 @@ aac_rkt_set_outb_queue(struct aac_softc { fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); - AAC_SETREG4(sc, AAC_RKT_OQUE, index); + AAC_MEM0_SETREG4(sc, AAC_RKT_OQUE, index); } /* Modified: stable/6/sys/dev/aac/aac_debug.c ============================================================================== --- stable/6/sys/dev/aac/aac_debug.c Wed Oct 28 12:10:29 2009 (r198539) +++ stable/6/sys/dev/aac/aac_debug.c Wed Oct 28 13:38:07 2009 (r198540) @@ -134,17 +134,18 @@ aac_printstate0(void) aac_print_queues(sc); switch (sc->aac_hwif) { case AAC_HWIF_I960RX: + case AAC_HWIF_NARK: device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x " - "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR), - AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR)); + "IISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_IDBR), + AAC_MEM0_GETREG4(sc, AAC_RX_IIMR), AAC_MEM0_GETREG4(sc, AAC_RX_IISR)); device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " - "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), - AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); - AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | + "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR), + AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR)); + AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/); device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " - "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), - AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); + "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR), + AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR)); break; case AAC_HWIF_STRONGARM: /* XXX implement */ Modified: stable/6/sys/dev/aac/aac_pci.c ============================================================================== --- stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 12:10:29 2009 (r198539) +++ stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 13:38:07 2009 (r198540) @@ -374,21 +374,32 @@ aac_pci_attach(device_t dev) /* * Allocate the PCI register window. */ - sc->aac_regs_rid = PCIR_BAR(0); - if ((sc->aac_regs_resource = bus_alloc_resource_any(sc->aac_dev, - SYS_RES_MEMORY, - &sc->aac_regs_rid, - RF_ACTIVE)) == - NULL) { + sc->aac_regs_rid0 = PCIR_BAR(0); + if ((sc->aac_regs_res0 = bus_alloc_resource_any(sc->aac_dev, + SYS_RES_MEMORY, &sc->aac_regs_rid0, RF_ACTIVE)) == NULL) { device_printf(sc->aac_dev, - "couldn't allocate register window\n"); + "couldn't allocate register window 0\n"); goto out; } - sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); - sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); + sc->aac_btag0 = rman_get_bustag(sc->aac_regs_res0); + sc->aac_bhandle0 = rman_get_bushandle(sc->aac_regs_res0); - /* assume failure is 'out of memory' */ - error = ENOMEM; + if (sc->aac_hwif == AAC_HWIF_NARK) { + sc->aac_regs_rid1 = PCIR_BAR(1); + if ((sc->aac_regs_res1 = bus_alloc_resource_any(sc->aac_dev, + SYS_RES_MEMORY, &sc->aac_regs_rid1, RF_ACTIVE)) == NULL) { + device_printf(sc->aac_dev, + "couldn't allocate register window 1\n"); + goto out; + } + sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1); + sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1); + } else { + sc->aac_regs_res1 = sc->aac_regs_res0; + sc->aac_regs_rid1 = sc->aac_regs_rid0; + sc->aac_btag1 = sc->aac_btag0; + sc->aac_bhandle1 = sc->aac_bhandle0; + } /* * Allocate the parent bus DMA tag appropriate for our PCI interface. @@ -418,7 +429,8 @@ aac_pci_attach(device_t dev) sc->aac_hwif = id->hwif; switch(sc->aac_hwif) { case AAC_HWIF_I960RX: - fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx"); + case AAC_HWIF_NARK: + fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx/NARK"); sc->aac_if = aac_rx_interface; break; case AAC_HWIF_STRONGARM: Modified: stable/6/sys/dev/aac/aacreg.h ============================================================================== --- stable/6/sys/dev/aac/aacreg.h Wed Oct 28 12:10:29 2009 (r198539) +++ stable/6/sys/dev/aac/aacreg.h Wed Oct 28 13:38:07 2009 (r198540) @@ -1468,7 +1468,7 @@ enum { #define AAC_FA_FWSTATUS 0x2c /* Mailbox 7 */ #define AAC_FA_INTSRC 0x900 -#define AAC_FA_HACK(sc) (void)AAC_GETREG4(sc, AAC_FA_INTSRC) +#define AAC_FA_HACK(sc) (void)AAC_MEM0_GETREG4(sc, AAC_FA_INTSRC) /* * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based Modified: stable/6/sys/dev/aac/aacvar.h ============================================================================== --- stable/6/sys/dev/aac/aacvar.h Wed Oct 28 12:10:29 2009 (r198539) +++ stable/6/sys/dev/aac/aacvar.h Wed Oct 28 13:38:07 2009 (r198540) @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -259,18 +260,31 @@ extern struct aac_interface aac_rkt_inte #define AAC_GET_OUTB_QUEUE(sc) ((sc)->aac_if.aif_get_outb_queue((sc))) #define AAC_SET_OUTB_QUEUE(sc, idx) ((sc)->aac_if.aif_set_outb_queue((sc), (idx))) -#define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \ - sc->aac_bhandle, reg) -#define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \ - sc->aac_bhandle, reg) -#define AAC_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag, \ - sc->aac_bhandle, reg, val) -#define AAC_GETREG1(sc, reg) bus_space_read_1 (sc->aac_btag, \ - sc->aac_bhandle, reg) +#define AAC_MEM0_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag0, \ + sc->aac_bhandle0, reg) +#define AAC_MEM0_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag0, \ + sc->aac_bhandle0, reg) +#define AAC_MEM0_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag0, \ + sc->aac_bhandle0, reg, val) +#define AAC_MEM0_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag0, \ + sc->aac_bhandle0, reg) + +#define AAC_MEM1_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag1, \ + sc->aac_bhandle1, reg) +#define AAC_MEM1_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag1, \ + sc->aac_bhandle1, reg) +#define AAC_MEM1_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag1, \ + sc->aac_bhandle1, reg, val) +#define AAC_MEM1_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag1, \ + sc->aac_bhandle1, reg) /* fib context (IOCTL) */ struct aac_fib_context { @@ -287,11 +301,10 @@ struct aac_softc { /* bus connections */ device_t aac_dev; - struct resource *aac_regs_resource; /* register interface - * window */ - int aac_regs_rid; /* resource ID */ - bus_space_handle_t aac_bhandle; /* bus space handle */ - bus_space_tag_t aac_btag; /* bus space tag */ + struct resource *aac_regs_res0, *aac_regs_res1; /* reg. if. window */ + int aac_regs_rid0, aac_regs_rid1; /* resource ID */ + bus_space_handle_t aac_bhandle0, aac_bhandle1; /* bus space handle */ + bus_space_tag_t aac_btag0, aac_btag1; /* bus space tag */ bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ bus_dma_tag_t aac_buffer_dmat; /* data buffer/command * DMA tag */ @@ -315,6 +328,7 @@ struct aac_softc #define AAC_HWIF_STRONGARM 1 #define AAC_HWIF_FALCON 2 #define AAC_HWIF_RKT 3 +#define AAC_HWIF_NARK 4 #define AAC_HWIF_UNKNOWN -1 bus_dma_tag_t aac_common_dmat; /* common structure * DMA tag */ @@ -398,6 +412,8 @@ struct aac_softc u_int32_t scsi_method_id; TAILQ_HEAD(,aac_sim) aac_sim_tqh; + struct callout aac_daemontime; /* clock daemon callout */ + u_int32_t aac_max_fibs; /* max. FIB count */ u_int32_t aac_max_fibs_alloc; /* max. alloc. per alloc_commands() */ u_int32_t aac_max_fib_size; /* max. FIB size */ From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 15:09:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F1B93106566C; Wed, 28 Oct 2009 15:09:21 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E00DB8FC12; Wed, 28 Oct 2009 15:09:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SF9L3E064700; Wed, 28 Oct 2009 15:09:21 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SF9Li2064698; Wed, 28 Oct 2009 15:09:21 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910281509.n9SF9Li2064698@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 15:09:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198545 - in stable/7/sys: . contrib/pf dev/aac X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 15:09:22 -0000 Author: emaste Date: Wed Oct 28 15:09:21 2009 New Revision: 198545 URL: http://svn.freebsd.org/changeset/base/198545 Log: MFC r185376: Remove duplicate 2610SA entry. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/aac/aac_pci.c Modified: stable/7/sys/dev/aac/aac_pci.c ============================================================================== --- stable/7/sys/dev/aac/aac_pci.c Wed Oct 28 15:01:18 2009 (r198544) +++ stable/7/sys/dev/aac/aac_pci.c Wed Oct 28 15:09:21 2009 (r198545) @@ -168,8 +168,6 @@ struct aac_ident "ICP ICP9014RO SCSI RAID"}, {0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0, "Adaptec SATA RAID 2026ZCR"}, - {0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, 0, - "Adaptec SATA RAID 2610SA"}, {0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0, "Adaptec SCSI RAID 2240S"}, {0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0, From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 15:36:55 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E01E51065676; Wed, 28 Oct 2009 15:36:55 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE75C8FC1B; Wed, 28 Oct 2009 15:36:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SFat5Q065381; Wed, 28 Oct 2009 15:36:55 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SFatZu065379; Wed, 28 Oct 2009 15:36:55 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910281536.n9SFatZu065379@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 15:36:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198547 - in stable/6/sys: . conf contrib/pf dev/aac dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 15:36:56 -0000 Author: emaste Date: Wed Oct 28 15:36:55 2009 New Revision: 198547 URL: http://svn.freebsd.org/changeset/base/198547 Log: MFC r185376: Remove duplicate 2610SA entry. Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/aac/aac_pci.c stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/dev/aac/aac_pci.c ============================================================================== --- stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 15:22:58 2009 (r198546) +++ stable/6/sys/dev/aac/aac_pci.c Wed Oct 28 15:36:55 2009 (r198547) @@ -168,8 +168,6 @@ struct aac_ident "ICP ICP9014RO SCSI RAID"}, {0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0, "Adaptec SATA RAID 2026ZCR"}, - {0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, 0, - "Adaptec SATA RAID 2610SA"}, {0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0, "Adaptec SCSI RAID 2240S"}, {0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0, From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 15:58:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADE5E106568F; Wed, 28 Oct 2009 15:58:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C8418FC0A; Wed, 28 Oct 2009 15:58:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SFwF5A065849; Wed, 28 Oct 2009 15:58:15 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SFwFQh065847; Wed, 28 Oct 2009 15:58:15 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200910281558.n9SFwFQh065847@svn.freebsd.org> From: Ed Maste Date: Wed, 28 Oct 2009 15:58:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198548 - stable/6/sys/dev/aac X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 15:58:15 -0000 Author: emaste Date: Wed Oct 28 15:58:15 2009 New Revision: 198548 URL: http://svn.freebsd.org/changeset/base/198548 Log: Replace callout_schedule (which doesn't exist on 6.x) with callout_reset. Modified: stable/6/sys/dev/aac/aac.c Modified: stable/6/sys/dev/aac/aac.c ============================================================================== --- stable/6/sys/dev/aac/aac.c Wed Oct 28 15:36:55 2009 (r198547) +++ stable/6/sys/dev/aac/aac.c Wed Oct 28 15:58:15 2009 (r198548) @@ -378,7 +378,7 @@ aac_daemon(void *arg) *(uint32_t *)fib->data = tv.tv_sec; aac_sync_fib(sc, SendHostTime, 0, fib, sizeof(uint32_t)); aac_release_sync_fib(sc); - callout_schedule(&sc->aac_daemontime, 30 * 60 * hz); + callout_reset(&sc->aac_daemontime, 30 * 60 * hz, aac_daemon, sc); } void From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 16:54:48 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2C071065676; Wed, 28 Oct 2009 16:54:48 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D16248FC2B; Wed, 28 Oct 2009 16:54:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SGsmDs066968; Wed, 28 Oct 2009 16:54:48 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SGsmW3066966; Wed, 28 Oct 2009 16:54:48 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910281654.n9SGsmW3066966@svn.freebsd.org> From: Christian Brueffer Date: Wed, 28 Oct 2009 16:54:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198549 - stable/8/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 16:54:49 -0000 Author: brueffer Date: Wed Oct 28 16:54:48 2009 New Revision: 198549 URL: http://svn.freebsd.org/changeset/base/198549 Log: MFC: r198313 Improve the description of the malofw kernel module installation. Modified: stable/8/share/man/man4/ (props changed) stable/8/share/man/man4/malo.4 Modified: stable/8/share/man/man4/malo.4 ============================================================================== --- stable/8/share/man/man4/malo.4 Wed Oct 28 15:58:15 2009 (r198548) +++ stable/8/share/man/man4/malo.4 Wed Oct 28 16:54:48 2009 (r198549) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\"/ -.Dd March 26, 2009 +.Dd October 21, 2009 .Dt MALO 4 .Os .Sh NAME @@ -71,14 +71,19 @@ For more information on configuring this .Pp This driver requires the .Nm malofw -be installed before it will work. +firmware kernel module be installed before it will work. The firmware files are not publicly available. -A package of the firmware which can be installed via -.Xr pkg_add 1 -with: +A port of the firmware can be found at: .Bd -literal -offset indent http://weongyo.org/project/malo/malo-firmware-1.4.tar.gz .Ed +.Pp +The firmware kernel module can be installed by extracting +the archive and running +.Ql make install clean +in the +.Pa malo-firmware-1.4 +directory. .Sh HARDWARE The following cards are among those supported by the .Nm From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 17:41:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CAF5106568D; Wed, 28 Oct 2009 17:41:29 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B5488FC21; Wed, 28 Oct 2009 17:41:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SHfTQN067942; Wed, 28 Oct 2009 17:41:29 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SHfTCR067940; Wed, 28 Oct 2009 17:41:29 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910281741.n9SHfTCR067940@svn.freebsd.org> From: Christian Brueffer Date: Wed, 28 Oct 2009 17:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198551 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 17:41:29 -0000 Author: brueffer Date: Wed Oct 28 17:41:29 2009 New Revision: 198551 URL: http://svn.freebsd.org/changeset/base/198551 Log: MFC: r198313 Improve the description of the malofw kernel module installation. Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/malo.4 Modified: stable/7/share/man/man4/malo.4 ============================================================================== --- stable/7/share/man/man4/malo.4 Wed Oct 28 17:03:20 2009 (r198550) +++ stable/7/share/man/man4/malo.4 Wed Oct 28 17:41:29 2009 (r198551) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\"/ -.Dd March 26, 2009 +.Dd October 21, 2009 .Dt MALO 4 .Os .Sh NAME @@ -69,25 +69,21 @@ The driver provides support for Marvell Libertas 88W8335 based PCI network adapters. .Pp -This driver requires firmware to be loaded before it will work. -These firmware files are from the -.Ox -.Nm -driver. -.Pp -A package for the firmware which can be installed via -.Xr pkg_add 1 -can be found at: +This driver requires the +.Nm malofw +firmware kernel module be installed before it will work. +The firmware files are not publicly available. +A port of the firmware can be found at: .Bd -literal -offset indent http://weongyo.org/project/malo/malo-firmware-1.4.tar.gz .Ed .Pp -This package must be installed before -.Xr ifconfig 8 -will work. -.Pp -For more information on configuring this device, see -.Xr ifconfig 8 . +The firmware kernel module can be installed by extracting +the archive and running +.Ql make install clean +in the +.Pa malo-firmware-1.4 +directory. .Sh HARDWARE The following cards are among those supported by the .Nm From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 17:46:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC2C3106568D; Wed, 28 Oct 2009 17:46:05 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A125E8FC19; Wed, 28 Oct 2009 17:46:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SHk5cc068082; Wed, 28 Oct 2009 17:46:05 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SHk5Cx068079; Wed, 28 Oct 2009 17:46:05 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910281746.n9SHk5Cx068079@svn.freebsd.org> From: Christian Brueffer Date: Wed, 28 Oct 2009 17:46:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198552 - stable/8/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 17:46:05 -0000 Author: brueffer Date: Wed Oct 28 17:46:05 2009 New Revision: 198552 URL: http://svn.freebsd.org/changeset/base/198552 Log: MFC: r198363 List more dependencies for these drivers. While here, convert atapicam(4) to use our standard section 4 SYNOPSIS layout. Modified: stable/8/share/man/man4/ (props changed) stable/8/share/man/man4/atapicam.4 stable/8/share/man/man4/umass.4 Modified: stable/8/share/man/man4/atapicam.4 ============================================================================== --- stable/8/share/man/man4/atapicam.4 Wed Oct 28 17:41:29 2009 (r198551) +++ stable/8/share/man/man4/atapicam.4 Wed Oct 28 17:46:05 2009 (r198552) @@ -27,14 +27,29 @@ .\" .\" $FreeBSD$ .\" -.Dd October 23, 2002 +.Dd October 22, 2009 .Dt ATAPICAM 4 .Os .Sh NAME .Nm atapicam .Nd CAM XPT (transport) module for ATAPI devices .Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device scbus" +.Cd "device cam" +.Cd "device ata" .Cd "device atapicam" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +atapicam_load="YES" +.Ed .Sh DESCRIPTION The ATAPI/CAM module allows ATAPI devices (CD-ROM, CD-RW, DVD drives, floppy drives such as Iomega Zip, tape drives) to be accessed through Modified: stable/8/share/man/man4/umass.4 ============================================================================== --- stable/8/share/man/man4/umass.4 Wed Oct 28 17:41:29 2009 (r198551) +++ stable/8/share/man/man4/umass.4 Wed Oct 28 17:46:05 2009 (r198552) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 22, 2006 +.Dd October 22, 2009 .Dt UMASS 4 .Os .Sh NAME @@ -38,6 +38,9 @@ To compile this driver into the kernel, place the following line in your kernel configuration file: .Bd -ragged -offset indent +.Cd "device scbus" +.Cd "device cam" +.Cd "device usb" .Cd "device umass" .Ed .Pp From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 17:46:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02BFF106566B; Wed, 28 Oct 2009 17:46:54 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB7C58FC27; Wed, 28 Oct 2009 17:46:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SHkqba068141; Wed, 28 Oct 2009 17:46:52 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SHkqBq068138; Wed, 28 Oct 2009 17:46:52 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910281746.n9SHkqBq068138@svn.freebsd.org> From: Christian Brueffer Date: Wed, 28 Oct 2009 17:46:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198553 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 17:46:54 -0000 Author: brueffer Date: Wed Oct 28 17:46:52 2009 New Revision: 198553 URL: http://svn.freebsd.org/changeset/base/198553 Log: MFC: r198363 List more dependencies for these drivers. While here, convert atapicam(4) to use our standard section 4 SYNOPSIS layout. Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/atapicam.4 stable/7/share/man/man4/umass.4 Modified: stable/7/share/man/man4/atapicam.4 ============================================================================== --- stable/7/share/man/man4/atapicam.4 Wed Oct 28 17:46:05 2009 (r198552) +++ stable/7/share/man/man4/atapicam.4 Wed Oct 28 17:46:52 2009 (r198553) @@ -27,14 +27,29 @@ .\" .\" $FreeBSD$ .\" -.Dd October 23, 2002 +.Dd October 22, 2009 .Dt ATAPICAM 4 .Os .Sh NAME .Nm atapicam .Nd CAM XPT (transport) module for ATAPI devices .Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device scbus" +.Cd "device cam" +.Cd "device ata" .Cd "device atapicam" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +atapicam_load="YES" +.Ed .Sh DESCRIPTION The ATAPI/CAM module allows ATAPI devices (CD-ROM, CD-RW, DVD drives, floppy drives such as Iomega Zip, tape drives) to be accessed through Modified: stable/7/share/man/man4/umass.4 ============================================================================== --- stable/7/share/man/man4/umass.4 Wed Oct 28 17:46:05 2009 (r198552) +++ stable/7/share/man/man4/umass.4 Wed Oct 28 17:46:52 2009 (r198553) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 22, 2006 +.Dd October 22, 2009 .Dt UMASS 4 .Os .Sh NAME @@ -38,6 +38,9 @@ To compile this driver into the kernel, place the following line in your kernel configuration file: .Bd -ragged -offset indent +.Cd "device scbus" +.Cd "device cam" +.Cd "device usb" .Cd "device umass" .Ed .Pp From owner-svn-src-stable@FreeBSD.ORG Wed Oct 28 21:07:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE6811065692; Wed, 28 Oct 2009 21:07:42 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB7AA8FC0C; Wed, 28 Oct 2009 21:07:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SL7gdO071983; Wed, 28 Oct 2009 21:07:42 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SL7gtp071979; Wed, 28 Oct 2009 21:07:42 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910282107.n9SL7gtp071979@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 28 Oct 2009 21:07:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198555 - stable/8/share/zoneinfo X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 21:07:43 -0000 Author: edwin Date: Wed Oct 28 21:07:42 2009 New Revision: 198555 URL: http://svn.freebsd.org/changeset/base/198555 Log: MFC of r197597, r198270, r198515: MFC of tzdata2009n: - Pakistan will go out DST on 1 October. - Headsup for changes in Argentina. MFC of tzdata2009o: - Somoa has not moved to DST this year (comment only) - Bangladesh stays on DST for now. - Pakistan went back to standard time in 1 October 2009 MFC of tzdata2009p: - Argentina does not go to DST this year. Approved by: re (Ken Smith) Modified: stable/8/share/zoneinfo/ (props changed) stable/8/share/zoneinfo/asia stable/8/share/zoneinfo/australasia stable/8/share/zoneinfo/southamerica Modified: stable/8/share/zoneinfo/asia ============================================================================== --- stable/8/share/zoneinfo/asia Wed Oct 28 20:17:54 2009 (r198554) +++ stable/8/share/zoneinfo/asia Wed Oct 28 21:07:42 2009 (r198555) @@ -1,5 +1,5 @@ #
-# @(#)asia	8.40
+# @(#)asia	8.42
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -172,11 +172,30 @@ Zone	Asia/Bahrain	3:22:20 -	LMT	1920		# 
 #
 # No DST end date has been announced yet.
 
-# From Arthur David Olson (2009-07-11):
-# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
-# can appear in the Dhaka binary file and for the benefit of old glibc
-# reimplementations of the time zone software that mishandle permanent DST.
-# A change will be required once the end date is known.
+# From Alexander Krivenyshev (2009-09-25):
+# Bangladesh won't go back to Standard Time from October 1, 2009, 
+# instead it will continue DST measure till the cabinet makes a fresh decision. 
+#
+# Following report by same newspaper-"The Daily Star Friday":
+# "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1"
+# 
+# http://www.thedailystar.net/newDesign/news-details.php?nid=107021
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html
+# 
+
+# From Steffen Thorsen (2009-10-13):
+# IANS (Indo-Asian News Service) now reports:
+# Bangladesh has decided that the clock advanced by an hour to make 
+# maximum use of daylight hours as an energy saving measure would 
+# "continue for an indefinite period."
+#
+# One of many places where it is published:
+# 
+# http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html
+# 
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
@@ -186,8 +205,7 @@ Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009 Jun 19 23:00 # Bangladesh Time
-			6:00	1:00	BDST	2010
-			6:00	-	BDT
+			6:00	1:00	BDST
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1674,16 +1692,66 @@ Zone	Asia/Muscat	3:54:20 -	LMT	1920
 # advance clocks in the country by one hour from April 15 to
 # conserve energy"
 
-# From Arthur David Olson (2009-04-10):
-# Assume for now that Pakistan will end DST in 2009 as it did in 2008.
+# From Steffen Thorsen (2009-09-17):
+# "The News International," Pakistan reports that: "The Federal
+# Government has decided to restore the previous time by moving the
+# clocks backward by one hour from October 1. A formal announcement to
+# this effect will be made after the Prime Minister grants approval in
+# this regard." 
+# 
+# http://www.thenews.com.pk/updates.asp?id=87168
+# 
+
+# From Alexander Krivenyshev (2009-09-28):
+# According to Associated Press Of Pakistan, it is confirmed that
+# Pakistan clocks across the country would be turned back by an hour from October
+# 1, 2009.
+#
+# "Clocks to go back one hour from 1 Oct"
+# 
+# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm
+# 
+
+# From Steffen Thorsen (2009-09-29):
+# Alexander Krivenyshev wrote:
+# > According to Associated Press Of Pakistan, it is confirmed that
+# > Pakistan clocks across the country would be turned back by an hour from October
+# > 1, 2009.
+#
+# Now they seem to have changed their mind, November 1 is the new date:
+# 
+# http://www.thenews.com.pk/top_story_detail.asp?Id=24742
+# 
+# "The country's clocks will be reversed by one hour on November 1.
+# Officials of Federal Ministry for Interior told this to Geo News on
+# Monday."
+#
+# And more importantly, it seems that these dates will be kept every year:
+# "It has now been decided that clocks will be wound forward by one hour
+# on April 15 and reversed by an hour on November 1 every year without
+# obtaining prior approval, the officials added."
+#
+# We have confirmed this year's end date with both with the Ministry of
+# Water and Power and the Pakistan Electric Power Company:
+# 
+# http://www.timeanddate.com/news/time/pakistan-ends-dst09.html
+# 
+
+# From Christoph Goehre (2009-10-01):
+# [T]he German Consulate General in Karachi reported me today that Pakistan
+# will go back to standard time on 1st of November.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Pakistan	2002	only	-	Apr	Sun>=2	0:01	1:00	S
 Rule Pakistan	2002	only	-	Oct	Sun>=2	0:01	0	-
 Rule Pakistan	2008	only	-	Jun	1	0:00	1:00	S
 Rule Pakistan	2008	only	-	Nov	1	0:00	0	-
-Rule Pakistan	2009	only	-	Apr	15	0:00	1:00	S
-Rule Pakistan	2009	only	-	Nov	1	0:00	0	-
+Rule Pakistan	2009	max	-	Apr	15	0:00	1:00	S
+Rule Pakistan	2009	max	-	Nov	1	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
 			5:30	-	IST	1942 Sep

Modified: stable/8/share/zoneinfo/australasia
==============================================================================
--- stable/8/share/zoneinfo/australasia	Wed Oct 28 20:17:54 2009	(r198554)
+++ stable/8/share/zoneinfo/australasia	Wed Oct 28 21:07:42 2009	(r198555)
@@ -1,5 +1,5 @@
 # 
-# @(#)australasia	8.13
+# @(#)australasia	8.14
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -457,6 +457,36 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 # http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
 # 
 
+# From Alexander Krivenyshev (2009-10-03):
+# First, my deepest condolences to people of Samoa islands and all families and
+# loved ones around the world who lost their lives in the earthquake and tsunami.
+#
+# Considering the recent devastation on Samoa by earthquake and tsunami and that
+# many government offices/ ministers are closed- not sure if "Daylight Saving
+# Bill 2009" will be implemented in next few days- on October 4, 2009.
+#
+# Here is reply from Consulate-General of Samoa in New Zealand
+# ---------------------------
+# Consul General
+# consulgeneral@samoaconsulate.org.nz
+#
+# Talofa Alexander,
+#
+# Thank you for your sympathy for our country but at this time we have not
+# been informed about the Daylight Savings Time Change.  Most Ministries in
+# Apia are closed or relocating due to weather concerns.
+#
+# When we do find out if they are still proceeding with the time change we
+# will advise you soonest.
+#
+# Kind Regards,
+# Lana
+# for: Consul General
+
+# From Steffen Thorsen (2009-10-05):
+# We have called a hotel in Samoa and asked about local time there - they 
+# are still on standard time.
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time

Modified: stable/8/share/zoneinfo/southamerica
==============================================================================
--- stable/8/share/zoneinfo/southamerica	Wed Oct 28 20:17:54 2009	(r198554)
+++ stable/8/share/zoneinfo/southamerica	Wed Oct 28 21:07:42 2009	(r198555)
@@ -1,5 +1,5 @@
 # 
-# @(#)southamerica	8.36
+# @(#)southamerica	8.40
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -215,9 +215,23 @@ Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 # http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
 # 
 
+# From fullinet (2009-10-18):
+# As announced in
+# 
+# http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356
+# 
+# (an official .gob.ar) under title: "Sin Cambio de Hora" (english: "No hour change")
+#
+# "Por el momento, el Gobierno Nacional resolvio no modificar la hora
+# oficial, decision que estaba en estudio para su implementacion el
+# domingo 18 de octubre. Desde el Ministerio de Planificacion se anuncio
+# que la Argentina hoy, en estas condiciones meteorologicas, no necesita
+# la modificacion del huso horario, ya que 2009 nos encuentra con
+# crecimiento en la produccion y distribucion energetica."
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
-Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
-Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S
+Rule	Arg	2008	2009	-	Mar	Sun>=15	0:00	0	-
+Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
  
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
@@ -389,15 +403,40 @@ Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:0
 # during 2009, this timezone change will run from 00:00 the third Sunday
 # in March until 24:00 of the second Saturday in October.
 
-# From Arthur David Olson (2009-03-16):
-# The unofficial claim at
-# 
-# http://www.timeanddate.com/news/time/san-luis-new-time-zone.html
-# 
-# is that "The province will most likely follow the next daylight saving schedule,
-# which is planned for the second Sunday in October."
-
+# From Mariano Absatz (2009-10-16):
+# ...the Province of San Luis is a case in itself.
 #
+# The Law at
+# 
+# is ambiguous because establishes a calendar from the 2nd Sunday in
+# October at 0:00 thru the 2nd Saturday in March at 24:00 and the
+# complement of that starting on the 2nd Sunday of March at 0:00 and
+# ending on the 2nd Saturday of March at 24:00.
+#
+# This clearly breaks every time the 1st of March or October is a Sunday.
+#
+# IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd
+# Sunday of October and March.
+#
+# The problem is that the changes in the rest of the Provinces that did
+# change in 2007/2008, were made according to the Federal Law and Decrees
+# that did so on the 3rd Sunday of October and March.
+#
+# In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday
+# (October 11th) at 0:00.
+#
+# So I guess a new set of rules, besides "Arg", must be made and the last
+# America/Argentina/San_Luis entries should change to use these...
+#
+# I'm enclosing a patch that does what I say... regretfully, the San Luis
+# timezone must be called "WART/WARST" even when most of the time (like,
+# right now) WARST == ART... that is, since last Sunday, all the country
+# is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
+# of the country calls it "ART".
+# ...
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Buenos Aires (BA), Capital Federal (CF),
@@ -530,6 +569,10 @@ Zone America/Argentina/Mendoza -4:35:16 
 			-3:00	-	ART
 #
 # San Luis (SL)
+
+Rule	SanLuis	2008	max	-	Mar	Sun>=8	0:00	0	-
+Rule	SanLuis	2007	max	-	Oct	Sun>=8	0:00	1:00	S
+
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
@@ -544,8 +587,7 @@ Zone America/Argentina/San_Luis -4:25:24
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
-			-3:00	-	ART	2009 Mar 15
-			-4:00	Arg	WAR%sT
+			-4:00	SanLuis	WAR%sT
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31

From owner-svn-src-stable@FreeBSD.ORG  Wed Oct 28 21:08:20 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D3692106568D;
	Wed, 28 Oct 2009 21:08:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A96C38FC18;
	Wed, 28 Oct 2009 21:08:20 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SL8Kdx072031;
	Wed, 28 Oct 2009 21:08:20 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SL8KG9072030;
	Wed, 28 Oct 2009 21:08:20 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910282108.n9SL8KG9072030@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 28 Oct 2009 21:08:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198556 - stable/8/usr.sbin/mfiutil
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 28 Oct 2009 21:08:20 -0000

Author: jhb
Date: Wed Oct 28 21:08:20 2009
New Revision: 198556
URL: http://svn.freebsd.org/changeset/base/198556

Log:
  MFC: Remove spurious README and an old version of the manpage.

Deleted:
  stable/8/usr.sbin/mfiutil/README
  stable/8/usr.sbin/mfiutil/mfiutil.1

From owner-svn-src-stable@FreeBSD.ORG  Wed Oct 28 21:13:13 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3FE951065676;
	Wed, 28 Oct 2009 21:13:13 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2CACE8FC29;
	Wed, 28 Oct 2009 21:13:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SLDDEY072388;
	Wed, 28 Oct 2009 21:13:13 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SLDDun072384;
	Wed, 28 Oct 2009 21:13:13 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <200910282113.n9SLDDun072384@svn.freebsd.org>
From: Edwin Groothuis 
Date: Wed, 28 Oct 2009 21:13:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198559 - stable/7/share/zoneinfo
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 28 Oct 2009 21:13:13 -0000

Author: edwin
Date: Wed Oct 28 21:13:12 2009
New Revision: 198559
URL: http://svn.freebsd.org/changeset/base/198559

Log:
  MFC of r198270, r198515.
  
  MFC of tzdata2009o:
  - Somoa has not moved to DST this year (comment only)
  - Bangladesh stays on DST for now.
  - Pakistan went back to standard time in 1 October 2009
  
  MFC of tzdata2009p:
  - Argentina does not go to DST this year.

Modified:
  stable/7/share/zoneinfo/   (props changed)
  stable/7/share/zoneinfo/asia
  stable/7/share/zoneinfo/australasia
  stable/7/share/zoneinfo/southamerica

Modified: stable/7/share/zoneinfo/asia
==============================================================================
--- stable/7/share/zoneinfo/asia	Wed Oct 28 21:12:34 2009	(r198558)
+++ stable/7/share/zoneinfo/asia	Wed Oct 28 21:13:12 2009	(r198559)
@@ -1,5 +1,5 @@
 # 
-# @(#)asia	8.41
+# @(#)asia	8.42
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -172,11 +172,30 @@ Zone	Asia/Bahrain	3:22:20 -	LMT	1920		# 
 #
 # No DST end date has been announced yet.
 
-# From Arthur David Olson (2009-07-11):
-# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
-# can appear in the Dhaka binary file and for the benefit of old glibc
-# reimplementations of the time zone software that mishandle permanent DST.
-# A change will be required once the end date is known.
+# From Alexander Krivenyshev (2009-09-25):
+# Bangladesh won't go back to Standard Time from October 1, 2009, 
+# instead it will continue DST measure till the cabinet makes a fresh decision. 
+#
+# Following report by same newspaper-"The Daily Star Friday":
+# "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1"
+# 
+# http://www.thedailystar.net/newDesign/news-details.php?nid=107021
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html
+# 
+
+# From Steffen Thorsen (2009-10-13):
+# IANS (Indo-Asian News Service) now reports:
+# Bangladesh has decided that the clock advanced by an hour to make 
+# maximum use of daylight hours as an energy saving measure would 
+# "continue for an indefinite period."
+#
+# One of many places where it is published:
+# 
+# http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html
+# 
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
@@ -186,8 +205,7 @@ Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009 Jun 19 23:00 # Bangladesh Time
-			6:00	1:00	BDST	2010
-			6:00	-	BDT
+			6:00	1:00	BDST
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1684,13 +1702,56 @@ Zone	Asia/Muscat	3:54:20 -	LMT	1920
 # http://www.thenews.com.pk/updates.asp?id=87168
 # 
 
+# From Alexander Krivenyshev (2009-09-28):
+# According to Associated Press Of Pakistan, it is confirmed that
+# Pakistan clocks across the country would be turned back by an hour from October
+# 1, 2009.
+#
+# "Clocks to go back one hour from 1 Oct"
+# 
+# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm
+# 
+
+# From Steffen Thorsen (2009-09-29):
+# Alexander Krivenyshev wrote:
+# > According to Associated Press Of Pakistan, it is confirmed that
+# > Pakistan clocks across the country would be turned back by an hour from October
+# > 1, 2009.
+#
+# Now they seem to have changed their mind, November 1 is the new date:
+# 
+# http://www.thenews.com.pk/top_story_detail.asp?Id=24742
+# 
+# "The country's clocks will be reversed by one hour on November 1.
+# Officials of Federal Ministry for Interior told this to Geo News on
+# Monday."
+#
+# And more importantly, it seems that these dates will be kept every year:
+# "It has now been decided that clocks will be wound forward by one hour
+# on April 15 and reversed by an hour on November 1 every year without
+# obtaining prior approval, the officials added."
+#
+# We have confirmed this year's end date with both with the Ministry of
+# Water and Power and the Pakistan Electric Power Company:
+# 
+# http://www.timeanddate.com/news/time/pakistan-ends-dst09.html
+# 
+
+# From Christoph Goehre (2009-10-01):
+# [T]he German Consulate General in Karachi reported me today that Pakistan
+# will go back to standard time on 1st of November.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Pakistan	2002	only	-	Apr	Sun>=2	0:01	1:00	S
 Rule Pakistan	2002	only	-	Oct	Sun>=2	0:01	0	-
 Rule Pakistan	2008	only	-	Jun	1	0:00	1:00	S
 Rule Pakistan	2008	only	-	Nov	1	0:00	0	-
-Rule Pakistan	2009	only	-	Apr	15	0:00	1:00	S
-Rule Pakistan	2009	only	-	Oct	1	0:00	0	-
+Rule Pakistan	2009	max	-	Apr	15	0:00	1:00	S
+Rule Pakistan	2009	max	-	Nov	1	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
 			5:30	-	IST	1942 Sep

Modified: stable/7/share/zoneinfo/australasia
==============================================================================
--- stable/7/share/zoneinfo/australasia	Wed Oct 28 21:12:34 2009	(r198558)
+++ stable/7/share/zoneinfo/australasia	Wed Oct 28 21:13:12 2009	(r198559)
@@ -1,5 +1,5 @@
 # 
-# @(#)australasia	8.13
+# @(#)australasia	8.14
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -457,6 +457,36 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 # http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
 # 
 
+# From Alexander Krivenyshev (2009-10-03):
+# First, my deepest condolences to people of Samoa islands and all families and
+# loved ones around the world who lost their lives in the earthquake and tsunami.
+#
+# Considering the recent devastation on Samoa by earthquake and tsunami and that
+# many government offices/ ministers are closed- not sure if "Daylight Saving
+# Bill 2009" will be implemented in next few days- on October 4, 2009.
+#
+# Here is reply from Consulate-General of Samoa in New Zealand
+# ---------------------------
+# Consul General
+# consulgeneral@samoaconsulate.org.nz
+#
+# Talofa Alexander,
+#
+# Thank you for your sympathy for our country but at this time we have not
+# been informed about the Daylight Savings Time Change.  Most Ministries in
+# Apia are closed or relocating due to weather concerns.
+#
+# When we do find out if they are still proceeding with the time change we
+# will advise you soonest.
+#
+# Kind Regards,
+# Lana
+# for: Consul General
+
+# From Steffen Thorsen (2009-10-05):
+# We have called a hotel in Samoa and asked about local time there - they 
+# are still on standard time.
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time

Modified: stable/7/share/zoneinfo/southamerica
==============================================================================
--- stable/7/share/zoneinfo/southamerica	Wed Oct 28 21:12:34 2009	(r198558)
+++ stable/7/share/zoneinfo/southamerica	Wed Oct 28 21:13:12 2009	(r198559)
@@ -1,5 +1,5 @@
 # 
-# @(#)southamerica	8.37
+# @(#)southamerica	8.40
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -215,9 +215,23 @@ Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 # http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
 # 
 
+# From fullinet (2009-10-18):
+# As announced in
+# 
+# http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356
+# 
+# (an official .gob.ar) under title: "Sin Cambio de Hora" (english: "No hour change")
+#
+# "Por el momento, el Gobierno Nacional resolvio no modificar la hora
+# oficial, decision que estaba en estudio para su implementacion el
+# domingo 18 de octubre. Desde el Ministerio de Planificacion se anuncio
+# que la Argentina hoy, en estas condiciones meteorologicas, no necesita
+# la modificacion del huso horario, ya que 2009 nos encuentra con
+# crecimiento en la produccion y distribucion energetica."
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
-Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
-Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S
+Rule	Arg	2008	2009	-	Mar	Sun>=15	0:00	0	-
+Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
  
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
@@ -389,44 +403,39 @@ Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:0
 # during 2009, this timezone change will run from 00:00 the third Sunday
 # in March until 24:00 of the second Saturday in October.
 
-# From Arthur David Olson (2009-03-16):
-# The unofficial claim at
-# 
-# http://www.timeanddate.com/news/time/san-luis-new-time-zone.html
-# 
-# is that "The province will most likely follow the next daylight saving schedule,
-# which is planned for the second Sunday in October."
-
-# From Alexander Krivenyshev (2009-09-19):
-# Some  Argentinian Provinces (Buenos Aires, Entre Ríos) are opposing to the
-# Daylight Saving Time for the 2009-2010 season.
-#
-# (Spanish)
-# "El cambio de huso horario en Entre Ríos deberá ser aprobado por la
-# Legislatura":
-# 
-# http://www.analisisdigital.com.ar/noticias.php?ed=1&di=0&no=110168
-# 
-# English translation - "The time zone change in Entre Rios must be approved by
-# the Legislature."
-#
-# (Spanish)
-# "Mar del Plata no quiere cambiar la hora."
-# 
-# http://www.mensajeroweb.com.ar/index.php?x=nota/33861/1/mar-del-plata-no-quiere-cambiar-la-hora
-# 
-# English translation - "Mar del Plata is not to change the time"
-#
-# or
-# (some English translation)
-# 
-# http://www.worldtimezone.com/dst_news/dst_news_argentina07.html
-# 
-
-# From Arthur David Olson (2009-09-22):
-# "Mar del Plata no quiere cambiar la hora" translates to
-# "Mar del Plata doesn't want to change the time"
-# (less definitive than "is not to").
+# From Mariano Absatz (2009-10-16):
+# ...the Province of San Luis is a case in itself.
+#
+# The Law at
+# 
+# is ambiguous because establishes a calendar from the 2nd Sunday in
+# October at 0:00 thru the 2nd Saturday in March at 24:00 and the
+# complement of that starting on the 2nd Sunday of March at 0:00 and
+# ending on the 2nd Saturday of March at 24:00.
+#
+# This clearly breaks every time the 1st of March or October is a Sunday.
+#
+# IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd
+# Sunday of October and March.
+#
+# The problem is that the changes in the rest of the Provinces that did
+# change in 2007/2008, were made according to the Federal Law and Decrees
+# that did so on the 3rd Sunday of October and March.
+#
+# In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday
+# (October 11th) at 0:00.
+#
+# So I guess a new set of rules, besides "Arg", must be made and the last
+# America/Argentina/San_Luis entries should change to use these...
+#
+# I'm enclosing a patch that does what I say... regretfully, the San Luis
+# timezone must be called "WART/WARST" even when most of the time (like,
+# right now) WARST == ART... that is, since last Sunday, all the country
+# is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
+# of the country calls it "ART".
+# ...
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
@@ -560,6 +569,10 @@ Zone America/Argentina/Mendoza -4:35:16 
 			-3:00	-	ART
 #
 # San Luis (SL)
+
+Rule	SanLuis	2008	max	-	Mar	Sun>=8	0:00	0	-
+Rule	SanLuis	2007	max	-	Oct	Sun>=8	0:00	1:00	S
+
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
@@ -574,8 +587,7 @@ Zone America/Argentina/San_Luis -4:25:24
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
-			-3:00	-	ART	2009 Mar 15
-			-4:00	Arg	WAR%sT
+			-4:00	SanLuis	WAR%sT
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31

From owner-svn-src-stable@FreeBSD.ORG  Wed Oct 28 21:13:58 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9B990106568B;
	Wed, 28 Oct 2009 21:13:58 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8849A8FC19;
	Wed, 28 Oct 2009 21:13:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SLDw0c072444;
	Wed, 28 Oct 2009 21:13:58 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SLDwx2072440;
	Wed, 28 Oct 2009 21:13:58 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <200910282113.n9SLDwx2072440@svn.freebsd.org>
From: Edwin Groothuis 
Date: Wed, 28 Oct 2009 21:13:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org
X-SVN-Group: stable-6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198560 - stable/6/share/zoneinfo
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 28 Oct 2009 21:13:58 -0000

Author: edwin
Date: Wed Oct 28 21:13:58 2009
New Revision: 198560
URL: http://svn.freebsd.org/changeset/base/198560

Log:
  MFC of r198270, r198515.
  
  MFC of tzdata2009o:
  - Somoa has not moved to DST this year (comment only)
  - Bangladesh stays on DST for now.
  - Pakistan went back to standard time in 1 October 2009
  
  MFC of tzdata2009p:
  - Argentina does not go to DST this year.

Modified:
  stable/6/share/zoneinfo/   (props changed)
  stable/6/share/zoneinfo/asia
  stable/6/share/zoneinfo/australasia
  stable/6/share/zoneinfo/southamerica

Modified: stable/6/share/zoneinfo/asia
==============================================================================
--- stable/6/share/zoneinfo/asia	Wed Oct 28 21:13:12 2009	(r198559)
+++ stable/6/share/zoneinfo/asia	Wed Oct 28 21:13:58 2009	(r198560)
@@ -1,5 +1,5 @@
 # 
-# @(#)asia	8.41
+# @(#)asia	8.42
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -172,11 +172,30 @@ Zone	Asia/Bahrain	3:22:20 -	LMT	1920		# 
 #
 # No DST end date has been announced yet.
 
-# From Arthur David Olson (2009-07-11):
-# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
-# can appear in the Dhaka binary file and for the benefit of old glibc
-# reimplementations of the time zone software that mishandle permanent DST.
-# A change will be required once the end date is known.
+# From Alexander Krivenyshev (2009-09-25):
+# Bangladesh won't go back to Standard Time from October 1, 2009, 
+# instead it will continue DST measure till the cabinet makes a fresh decision. 
+#
+# Following report by same newspaper-"The Daily Star Friday":
+# "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1"
+# 
+# http://www.thedailystar.net/newDesign/news-details.php?nid=107021
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html
+# 
+
+# From Steffen Thorsen (2009-10-13):
+# IANS (Indo-Asian News Service) now reports:
+# Bangladesh has decided that the clock advanced by an hour to make 
+# maximum use of daylight hours as an energy saving measure would 
+# "continue for an indefinite period."
+#
+# One of many places where it is published:
+# 
+# http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html
+# 
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
@@ -186,8 +205,7 @@ Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009 Jun 19 23:00 # Bangladesh Time
-			6:00	1:00	BDST	2010
-			6:00	-	BDT
+			6:00	1:00	BDST
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1684,13 +1702,56 @@ Zone	Asia/Muscat	3:54:20 -	LMT	1920
 # http://www.thenews.com.pk/updates.asp?id=87168
 # 
 
+# From Alexander Krivenyshev (2009-09-28):
+# According to Associated Press Of Pakistan, it is confirmed that
+# Pakistan clocks across the country would be turned back by an hour from October
+# 1, 2009.
+#
+# "Clocks to go back one hour from 1 Oct"
+# 
+# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm
+# 
+
+# From Steffen Thorsen (2009-09-29):
+# Alexander Krivenyshev wrote:
+# > According to Associated Press Of Pakistan, it is confirmed that
+# > Pakistan clocks across the country would be turned back by an hour from October
+# > 1, 2009.
+#
+# Now they seem to have changed their mind, November 1 is the new date:
+# 
+# http://www.thenews.com.pk/top_story_detail.asp?Id=24742
+# 
+# "The country's clocks will be reversed by one hour on November 1.
+# Officials of Federal Ministry for Interior told this to Geo News on
+# Monday."
+#
+# And more importantly, it seems that these dates will be kept every year:
+# "It has now been decided that clocks will be wound forward by one hour
+# on April 15 and reversed by an hour on November 1 every year without
+# obtaining prior approval, the officials added."
+#
+# We have confirmed this year's end date with both with the Ministry of
+# Water and Power and the Pakistan Electric Power Company:
+# 
+# http://www.timeanddate.com/news/time/pakistan-ends-dst09.html
+# 
+
+# From Christoph Goehre (2009-10-01):
+# [T]he German Consulate General in Karachi reported me today that Pakistan
+# will go back to standard time on 1st of November.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Pakistan	2002	only	-	Apr	Sun>=2	0:01	1:00	S
 Rule Pakistan	2002	only	-	Oct	Sun>=2	0:01	0	-
 Rule Pakistan	2008	only	-	Jun	1	0:00	1:00	S
 Rule Pakistan	2008	only	-	Nov	1	0:00	0	-
-Rule Pakistan	2009	only	-	Apr	15	0:00	1:00	S
-Rule Pakistan	2009	only	-	Oct	1	0:00	0	-
+Rule Pakistan	2009	max	-	Apr	15	0:00	1:00	S
+Rule Pakistan	2009	max	-	Nov	1	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
 			5:30	-	IST	1942 Sep

Modified: stable/6/share/zoneinfo/australasia
==============================================================================
--- stable/6/share/zoneinfo/australasia	Wed Oct 28 21:13:12 2009	(r198559)
+++ stable/6/share/zoneinfo/australasia	Wed Oct 28 21:13:58 2009	(r198560)
@@ -1,5 +1,5 @@
 # 
-# @(#)australasia	8.13
+# @(#)australasia	8.14
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -457,6 +457,36 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 # http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
 # 
 
+# From Alexander Krivenyshev (2009-10-03):
+# First, my deepest condolences to people of Samoa islands and all families and
+# loved ones around the world who lost their lives in the earthquake and tsunami.
+#
+# Considering the recent devastation on Samoa by earthquake and tsunami and that
+# many government offices/ ministers are closed- not sure if "Daylight Saving
+# Bill 2009" will be implemented in next few days- on October 4, 2009.
+#
+# Here is reply from Consulate-General of Samoa in New Zealand
+# ---------------------------
+# Consul General
+# consulgeneral@samoaconsulate.org.nz
+#
+# Talofa Alexander,
+#
+# Thank you for your sympathy for our country but at this time we have not
+# been informed about the Daylight Savings Time Change.  Most Ministries in
+# Apia are closed or relocating due to weather concerns.
+#
+# When we do find out if they are still proceeding with the time change we
+# will advise you soonest.
+#
+# Kind Regards,
+# Lana
+# for: Consul General
+
+# From Steffen Thorsen (2009-10-05):
+# We have called a hotel in Samoa and asked about local time there - they 
+# are still on standard time.
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time

Modified: stable/6/share/zoneinfo/southamerica
==============================================================================
--- stable/6/share/zoneinfo/southamerica	Wed Oct 28 21:13:12 2009	(r198559)
+++ stable/6/share/zoneinfo/southamerica	Wed Oct 28 21:13:58 2009	(r198560)
@@ -1,5 +1,5 @@
 # 
-# @(#)southamerica	8.37
+# @(#)southamerica	8.40
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -215,9 +215,23 @@ Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 # http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
 # 
 
+# From fullinet (2009-10-18):
+# As announced in
+# 
+# http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356
+# 
+# (an official .gob.ar) under title: "Sin Cambio de Hora" (english: "No hour change")
+#
+# "Por el momento, el Gobierno Nacional resolvio no modificar la hora
+# oficial, decision que estaba en estudio para su implementacion el
+# domingo 18 de octubre. Desde el Ministerio de Planificacion se anuncio
+# que la Argentina hoy, en estas condiciones meteorologicas, no necesita
+# la modificacion del huso horario, ya que 2009 nos encuentra con
+# crecimiento en la produccion y distribucion energetica."
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
-Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
-Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S
+Rule	Arg	2008	2009	-	Mar	Sun>=15	0:00	0	-
+Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
  
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
@@ -389,44 +403,39 @@ Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:0
 # during 2009, this timezone change will run from 00:00 the third Sunday
 # in March until 24:00 of the second Saturday in October.
 
-# From Arthur David Olson (2009-03-16):
-# The unofficial claim at
-# 
-# http://www.timeanddate.com/news/time/san-luis-new-time-zone.html
-# 
-# is that "The province will most likely follow the next daylight saving schedule,
-# which is planned for the second Sunday in October."
-
-# From Alexander Krivenyshev (2009-09-19):
-# Some  Argentinian Provinces (Buenos Aires, Entre Ríos) are opposing to the
-# Daylight Saving Time for the 2009-2010 season.
-#
-# (Spanish)
-# "El cambio de huso horario en Entre Ríos deberá ser aprobado por la
-# Legislatura":
-# 
-# http://www.analisisdigital.com.ar/noticias.php?ed=1&di=0&no=110168
-# 
-# English translation - "The time zone change in Entre Rios must be approved by
-# the Legislature."
-#
-# (Spanish)
-# "Mar del Plata no quiere cambiar la hora."
-# 
-# http://www.mensajeroweb.com.ar/index.php?x=nota/33861/1/mar-del-plata-no-quiere-cambiar-la-hora
-# 
-# English translation - "Mar del Plata is not to change the time"
-#
-# or
-# (some English translation)
-# 
-# http://www.worldtimezone.com/dst_news/dst_news_argentina07.html
-# 
-
-# From Arthur David Olson (2009-09-22):
-# "Mar del Plata no quiere cambiar la hora" translates to
-# "Mar del Plata doesn't want to change the time"
-# (less definitive than "is not to").
+# From Mariano Absatz (2009-10-16):
+# ...the Province of San Luis is a case in itself.
+#
+# The Law at
+# 
+# is ambiguous because establishes a calendar from the 2nd Sunday in
+# October at 0:00 thru the 2nd Saturday in March at 24:00 and the
+# complement of that starting on the 2nd Sunday of March at 0:00 and
+# ending on the 2nd Saturday of March at 24:00.
+#
+# This clearly breaks every time the 1st of March or October is a Sunday.
+#
+# IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd
+# Sunday of October and March.
+#
+# The problem is that the changes in the rest of the Provinces that did
+# change in 2007/2008, were made according to the Federal Law and Decrees
+# that did so on the 3rd Sunday of October and March.
+#
+# In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday
+# (October 11th) at 0:00.
+#
+# So I guess a new set of rules, besides "Arg", must be made and the last
+# America/Argentina/San_Luis entries should change to use these...
+#
+# I'm enclosing a patch that does what I say... regretfully, the San Luis
+# timezone must be called "WART/WARST" even when most of the time (like,
+# right now) WARST == ART... that is, since last Sunday, all the country
+# is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
+# of the country calls it "ART".
+# ...
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
@@ -560,6 +569,10 @@ Zone America/Argentina/Mendoza -4:35:16 
 			-3:00	-	ART
 #
 # San Luis (SL)
+
+Rule	SanLuis	2008	max	-	Mar	Sun>=8	0:00	0	-
+Rule	SanLuis	2007	max	-	Oct	Sun>=8	0:00	1:00	S
+
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
@@ -574,8 +587,7 @@ Zone America/Argentina/San_Luis -4:25:24
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
-			-3:00	-	ART	2009 Mar 15
-			-4:00	Arg	WAR%sT
+			-4:00	SanLuis	WAR%sT
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31

From owner-svn-src-stable@FreeBSD.ORG  Wed Oct 28 21:43:16 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EF6771065670;
	Wed, 28 Oct 2009 21:43:16 +0000 (UTC)
	(envelope-from qingli@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DCB5F8FC2A;
	Wed, 28 Oct 2009 21:43:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SLhGeY073292;
	Wed, 28 Oct 2009 21:43:16 GMT (envelope-from qingli@svn.freebsd.org)
Received: (from qingli@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SLhGhd073290;
	Wed, 28 Oct 2009 21:43:16 GMT (envelope-from qingli@svn.freebsd.org)
Message-Id: <200910282143.n9SLhGhd073290@svn.freebsd.org>
From: Qing Li 
Date: Wed, 28 Oct 2009 21:43:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198566 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci net
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 28 Oct 2009 21:43:17 -0000

Author: qingli
Date: Wed Oct 28 21:43:16 2009
New Revision: 198566
URL: http://svn.freebsd.org/changeset/base/198566

Log:
  MFC	r198353
  
  Verify "smp_started" is true before calling
  sched_bind() and sched_unbind().
  
  Reviewed by:	kmacy

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/flowtable.c

Modified: stable/8/sys/net/flowtable.c
==============================================================================
--- stable/8/sys/net/flowtable.c	Wed Oct 28 21:41:23 2009	(r198565)
+++ stable/8/sys/net/flowtable.c	Wed Oct 28 21:43:16 2009	(r198566)
@@ -963,15 +963,19 @@ flowtable_clean_vnet(void)
 				if (CPU_ABSENT(i))
 					continue;
 
-				thread_lock(curthread);
-				sched_bind(curthread, i);
-				thread_unlock(curthread);
+				if (smp_started == 1) {
+					thread_lock(curthread);
+					sched_bind(curthread, i);
+					thread_unlock(curthread);
+				}
 
 				flowtable_free_stale(ft, NULL);
 
-				thread_lock(curthread);
-				sched_unbind(curthread);
-				thread_unlock(curthread);
+				if (smp_started == 1) {
+					thread_lock(curthread);
+					sched_unbind(curthread);
+					thread_unlock(curthread);
+				}
 			}
 		} else {
 			flowtable_free_stale(ft, NULL);

From owner-svn-src-stable@FreeBSD.ORG  Wed Oct 28 21:45:25 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B657D1065679;
	Wed, 28 Oct 2009 21:45:25 +0000 (UTC)
	(envelope-from qingli@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A38308FC1C;
	Wed, 28 Oct 2009 21:45:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SLjPKD073402;
	Wed, 28 Oct 2009 21:45:25 GMT (envelope-from qingli@svn.freebsd.org)
Received: (from qingli@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SLjPek073398;
	Wed, 28 Oct 2009 21:45:25 GMT (envelope-from qingli@svn.freebsd.org)
Message-Id: <200910282145.n9SLjPek073398@svn.freebsd.org>
From: Qing Li 
Date: Wed, 28 Oct 2009 21:45:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198567 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci netinet netinet6
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 28 Oct 2009 21:45:25 -0000

Author: qingli
Date: Wed Oct 28 21:45:25 2009
New Revision: 198567
URL: http://svn.freebsd.org/changeset/base/198567

Log:
  MFC	r198418
  
  Use the correct option name in the preprocessor command to enable
  or disable diagnostic messages.
  
  Reviewed by:	ru

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/netinet/if_ether.c
  stable/8/sys/netinet/in.c
  stable/8/sys/netinet6/in6.c

Modified: stable/8/sys/netinet/if_ether.c
==============================================================================
--- stable/8/sys/netinet/if_ether.c	Wed Oct 28 21:43:16 2009	(r198566)
+++ stable/8/sys/netinet/if_ether.c	Wed Oct 28 21:45:25 2009	(r198567)
@@ -172,7 +172,7 @@ arptimer(void *arg)
 	    callout_active(&lle->la_timer))) {
 		(void) llentry_free(lle);
 	}
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
 	else {
 		struct sockaddr *l3addr = L3_ADDR(lle);
 		log(LOG_INFO, "arptimer issue: %p, IPv4 address: \"%s\"\n", lle,

Modified: stable/8/sys/netinet/in.c
==============================================================================
--- stable/8/sys/netinet/in.c	Wed Oct 28 21:43:16 2009	(r198566)
+++ stable/8/sys/netinet/in.c	Wed Oct 28 21:45:25 2009	(r198567)
@@ -1327,7 +1327,7 @@ in_lltable_rtcheck(struct ifnet *ifp, co
 	/* XXX rtalloc1 should take a const param */
 	rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0);
 	if (rt == NULL || (rt->rt_flags & RTF_GATEWAY) || rt->rt_ifp != ifp) {
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
 		log(LOG_INFO, "IPv4 address: \"%s\" is not on the network\n",
 		    inet_ntoa(((const struct sockaddr_in *)l3addr)->sin_addr));
 #endif
@@ -1366,7 +1366,7 @@ in_lltable_lookup(struct lltable *llt, u
 			break;
 	}
 	if (lle == NULL) {
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
 		if (flags & LLE_DELETE)
 			log(LOG_INFO, "interface address is missing from cache = %p  in delete\n", lle);	
 #endif
@@ -1400,7 +1400,7 @@ in_lltable_lookup(struct lltable *llt, u
 			LLE_WLOCK(lle);
 			lle->la_flags = LLE_DELETED;
 			LLE_WUNLOCK(lle);
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
 			log(LOG_INFO, "ifaddr cache = %p  is deleted\n", lle);	
 #endif
 		}

Modified: stable/8/sys/netinet6/in6.c
==============================================================================
--- stable/8/sys/netinet6/in6.c	Wed Oct 28 21:43:16 2009	(r198566)
+++ stable/8/sys/netinet6/in6.c	Wed Oct 28 21:45:25 2009	(r198567)
@@ -2430,7 +2430,7 @@ in6_lltable_lookup(struct lltable *llt, 
 			LLE_WLOCK(lle);
 			lle->la_flags = LLE_DELETED;
 			LLE_WUNLOCK(lle);
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
 			log(LOG_INFO, "ifaddr cache = %p  is deleted\n", lle);	
 #endif	
 		}

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 09:45:49 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15DA9106568D;
	Thu, 29 Oct 2009 09:45:49 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 02DD28FC1C;
	Thu, 29 Oct 2009 09:45:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9T9jmd5090425;
	Thu, 29 Oct 2009 09:45:48 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9T9jm2f090423;
	Thu, 29 Oct 2009 09:45:48 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910290945.n9T9jm2f090423@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 29 Oct 2009 09:45:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198572 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/ata/chipsets dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 09:45:49 -0000

Author: mav
Date: Thu Oct 29 09:45:48 2009
New Revision: 198572
URL: http://svn.freebsd.org/changeset/base/198572

Log:
  Fix SATA on nVidia MCP55 chipset. It needs some short time to allow BAR(5)
  memory access.
  
  PR:		amd64/128686, amd64/132372, amd64/139156

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/ata/chipsets/ata-nvidia.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/ata/chipsets/ata-nvidia.c
==============================================================================
--- stable/8/sys/dev/ata/chipsets/ata-nvidia.c	Thu Oct 29 09:45:05 2009	(r198571)
+++ stable/8/sys/dev/ata/chipsets/ata-nvidia.c	Thu Oct 29 09:45:48 2009	(r198572)
@@ -165,7 +165,8 @@ ata_nvidia_chipinit(device_t dev)
 
 	    /* enable control access */
 	    pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 1) | 0x04,1);
-
+	    /* MCP55 seems to need some time to allow r_res2 read. */
+	    DELAY(10);
 	    if (ctlr->chip->cfg1 & NVQ) {
 		/* clear interrupt status */
 		ATA_OUTL(ctlr->r_res2, offset, 0x00ff00ff);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 09:58:16 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7BDC9106566C;
	Thu, 29 Oct 2009 09:58:16 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 672E08FC28;
	Thu, 29 Oct 2009 09:58:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9T9wGsv090811;
	Thu, 29 Oct 2009 09:58:16 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9T9wGVD090808;
	Thu, 29 Oct 2009 09:58:16 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910290958.n9T9wGVD090808@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 29 Oct 2009 09:58:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198574 - in stable/8: . bin/csh bin/sh
	cddl/compat/opensolaris cddl/contrib/opensolaris
	cddl/lib/libnvpair contrib/bind9 contrib/bzip2 contrib/cpio
	contrib/csup contrib/ee contrib/file...
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 09:58:16 -0000

Author: mav
Date: Thu Oct 29 09:58:16 2009
New Revision: 198574
URL: http://svn.freebsd.org/changeset/base/198574

Log:
  MFC rev. 198480, 198483:
  Document new modularised ATA kernel modules and options.
  
  PR:             kern/133162, amd64/139859

Modified:
  stable/8/   (props changed)
  stable/8/ObsoleteFiles.inc   (props changed)
  stable/8/UPDATING   (contents, props changed)
  stable/8/bin/csh/   (props changed)
  stable/8/bin/sh/   (props changed)
  stable/8/cddl/compat/opensolaris/   (props changed)
  stable/8/cddl/contrib/opensolaris/   (props changed)
  stable/8/cddl/lib/libnvpair/   (props changed)
  stable/8/contrib/bind9/   (props changed)
  stable/8/contrib/bzip2/   (props changed)
  stable/8/contrib/cpio/   (props changed)
  stable/8/contrib/csup/   (props changed)
  stable/8/contrib/ee/   (props changed)
  stable/8/contrib/file/   (props changed)
  stable/8/contrib/gdb/   (props changed)
  stable/8/contrib/gdtoa/   (props changed)
  stable/8/contrib/less/   (props changed)
  stable/8/contrib/libpcap/   (props changed)
  stable/8/contrib/ncurses/   (props changed)
  stable/8/contrib/netcat/   (props changed)
  stable/8/contrib/ntp/   (props changed)
  stable/8/contrib/openbsm/   (props changed)
  stable/8/contrib/openpam/   (props changed)
  stable/8/contrib/pf/   (props changed)
  stable/8/contrib/sendmail/   (props changed)
  stable/8/contrib/tcpdump/   (props changed)
  stable/8/contrib/tcsh/   (props changed)
  stable/8/contrib/top/   (props changed)
  stable/8/contrib/top/install-sh   (props changed)
  stable/8/contrib/traceroute/   (props changed)
  stable/8/contrib/wpa/   (props changed)
  stable/8/crypto/openssh/   (props changed)
  stable/8/crypto/openssl/   (props changed)
  stable/8/etc/   (props changed)
  stable/8/gnu/usr.bin/patch/   (props changed)
  stable/8/include/   (props changed)
  stable/8/kerberos5/lib/libgssapi_krb5/   (props changed)
  stable/8/kerberos5/lib/libgssapi_spnego/   (props changed)
  stable/8/lib/libarchive/   (props changed)
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/gen/   (props changed)
  stable/8/lib/libc/stdio/asprintf.c   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/string/ffsll.c   (props changed)
  stable/8/lib/libc/string/flsll.c   (props changed)
  stable/8/lib/libc/string/wcpcpy.c   (props changed)
  stable/8/lib/libc/string/wcpncpy.c   (props changed)
  stable/8/lib/libdevinfo/   (props changed)
  stable/8/lib/libdisk/   (props changed)
  stable/8/lib/libkvm/   (props changed)
  stable/8/lib/libthr/   (props changed)
  stable/8/lib/libusb/   (props changed)
  stable/8/lib/libusb/usb.h   (props changed)
  stable/8/lib/libutil/   (props changed)
  stable/8/libexec/rtld-elf/   (props changed)
  stable/8/release/   (props changed)
  stable/8/release/doc/   (props changed)
  stable/8/release/doc/en_US.ISO8859-1/hardware/   (props changed)
  stable/8/sbin/   (props changed)
  stable/8/sbin/bsdlabel/   (props changed)
  stable/8/sbin/camcontrol/   (props changed)
  stable/8/sbin/dhclient/   (props changed)
  stable/8/sbin/geom/   (props changed)
  stable/8/sbin/ifconfig/   (props changed)
  stable/8/sbin/ipfw/   (props changed)
  stable/8/sbin/mksnap_ffs/   (props changed)
  stable/8/sbin/mount/   (props changed)
  stable/8/sbin/mount_nfs/   (props changed)
  stable/8/sbin/umount/   (props changed)
  stable/8/share/man/man4/   (props changed)
  stable/8/share/man/man5/   (props changed)
  stable/8/share/man/man7/   (props changed)
  stable/8/share/man/man9/   (props changed)
  stable/8/share/timedef/   (props changed)
  stable/8/share/zoneinfo/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/conf/NOTES
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/tools/regression/bin/sh/   (props changed)
  stable/8/tools/regression/lib/msun/test-conj.t   (props changed)
  stable/8/tools/regression/poll/   (props changed)
  stable/8/tools/regression/priv/   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pgrep-_g.t   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pgrep-_s.t   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pkill-_g.t   (props changed)
  stable/8/tools/tools/ath/common/dumpregs.h   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5210.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5211.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5212.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5416.c   (props changed)
  stable/8/tools/tools/termcap/termcap.pl   (props changed)
  stable/8/tools/tools/vimage/   (props changed)
  stable/8/usr.bin/calendar/calendars/calendar.freebsd   (props changed)
  stable/8/usr.bin/csup/   (props changed)
  stable/8/usr.bin/fstat/   (props changed)
  stable/8/usr.bin/look/   (props changed)
  stable/8/usr.bin/netstat/   (props changed)
  stable/8/usr.bin/procstat/   (props changed)
  stable/8/usr.bin/w/   (props changed)
  stable/8/usr.bin/whois/   (props changed)
  stable/8/usr.sbin/   (props changed)
  stable/8/usr.sbin/arp/   (props changed)
  stable/8/usr.sbin/dumpcis/cardinfo.h   (props changed)
  stable/8/usr.sbin/dumpcis/cis.h   (props changed)
  stable/8/usr.sbin/freebsd-update/   (props changed)
  stable/8/usr.sbin/iostat/   (props changed)
  stable/8/usr.sbin/jls/   (props changed)
  stable/8/usr.sbin/lpr/   (props changed)
  stable/8/usr.sbin/makefs/ffs/ffs_bswap.c   (props changed)
  stable/8/usr.sbin/makefs/ffs/ffs_subr.c   (props changed)
  stable/8/usr.sbin/makefs/ffs/ufs_bswap.h   (props changed)
  stable/8/usr.sbin/makefs/getid.c   (props changed)
  stable/8/usr.sbin/mfiutil/mfiutil.8   (props changed)
  stable/8/usr.sbin/ndp/   (props changed)
  stable/8/usr.sbin/ntp/   (props changed)
  stable/8/usr.sbin/ppp/   (props changed)
  stable/8/usr.sbin/pstat/   (props changed)
  stable/8/usr.sbin/sysinstall/   (props changed)
  stable/8/usr.sbin/traceroute6/   (props changed)
  stable/8/usr.sbin/wpa/   (props changed)
  stable/8/usr.sbin/zic/   (props changed)

Modified: stable/8/UPDATING
==============================================================================
--- stable/8/UPDATING	Thu Oct 29 09:51:13 2009	(r198573)
+++ stable/8/UPDATING	Thu Oct 29 09:58:16 2009	(r198574)
@@ -566,6 +566,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
 	userland (libpmc(3)) and the kernel module (hwpmc(4)) in
 	sync.
 
+20081009:
+	atapci kernel module now includes only generic PCI ATA
+	driver. AHCI driver moved to ataahci kernel module.
+	All vendor-specific code moved into separate kernel modules:
+	ataacard, ataacerlabs, ataadaptec, ataamd, ataati, atacenatek,
+	atacypress, atacyrix, atahighpoint, ataintel, ataite, atajmicron,
+	atamarvell, atamicron, atanational, atanetcell, atanvidia,
+	atapromise, ataserverworks, atasiliconimage, atasis, atavia
+
 20080820:
 	The TTY subsystem of the kernel has been replaced by a new
 	implementation, which provides better scalability and an

Modified: stable/8/sys/conf/NOTES
==============================================================================
--- stable/8/sys/conf/NOTES	Thu Oct 29 09:51:13 2009	(r198573)
+++ stable/8/sys/conf/NOTES	Thu Oct 29 09:58:16 2009	(r198574)
@@ -1657,6 +1657,10 @@ device		siis
 # The 'ATA' driver supports all ATA and ATAPI devices, including PC Card
 # devices. You only need one "device ata" for it to find all
 # PCI and PC Card ATA/ATAPI devices on modern machines.
+# Alternatively, individual bus and chipset drivers may be chosen by using
+# the 'atacore' driver then selecting the drivers on a per vendor basis.
+# For example to build a system which only supports a VIA chipset,
+# omit 'ata' and include the 'atacore', 'atapci' and 'atavia' drivers.
 device		ata
 device		atadisk		# ATA disk drives
 device		ataraid		# ATA RAID drives
@@ -1665,6 +1669,39 @@ device		atapifd		# ATAPI floppy drives
 device		atapist		# ATAPI tape drives
 device		atapicam	# emulate ATAPI devices as SCSI ditto via CAM
 				# needs CAM to be present (scbus & pass)
+
+# Modular ATA
+#device		atacore		# Core ATA functionality
+#device		atacard		# CARDBUS support
+#device		atabus		# PC98 cbus support
+#device		ataisa		# ISA bus support
+#device		atapci		# PCI bus support; only generic chipset support
+
+# PCI ATA chipsets
+#device		ataahci		# AHCI SATA
+#device		ataacard	# ACARD
+#device		ataacerlabs	# Acer Labs Inc. (ALI)
+#device		ataadaptec	# Adaptec
+#device		ataamd		# American Micro Devices (AMD)
+#device		ataati		# ATI
+#device		atacenatek	# Cenatek
+#device		atacypress	# Cypress
+#device		atacyrix	# Cyrix
+#device		atahighpoint	# HighPoint
+#device		ataintel	# Intel
+#device		ataite		# Integrated Technology Inc. (ITE)
+#device		atajmicron	# JMicron
+#device		atamarvell	# Marvell
+#device		atamicron	# Micron
+#device		atanational	# National
+#device		atanetcell	# NetCell
+#device		atanvidia	# nVidia
+#device		atapromise	# Promise
+#device		ataserverworks	# ServerWorks
+#device		atasiliconimage	# Silicon Image Inc. (SiI) (formerly CMD)
+#device		atasis		# Silicon Integrated Systems Corp.(SiS)
+#device		atavia		# VIA Technologies Inc.
+
 #
 # For older non-PCI, non-PnPBIOS systems, these are the hints lines to add:
 hint.ata.0.at="isa"

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 10:05:08 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E738E106568F;
	Thu, 29 Oct 2009 10:05:08 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D40E08FC28;
	Thu, 29 Oct 2009 10:05:08 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TA58mH091197;
	Thu, 29 Oct 2009 10:05:08 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TA585X091194;
	Thu, 29 Oct 2009 10:05:08 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910291005.n9TA585X091194@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 29 Oct 2009 10:05:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198576 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/ata dev/ata/chipsets dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 10:05:09 -0000

Author: mav
Date: Thu Oct 29 10:05:08 2009
New Revision: 198576
URL: http://svn.freebsd.org/changeset/base/198576

Log:
  MFC rev. 198481, 198482:
  Add two more VIA SATA chip IDs.
  
  PR:		kern/135057

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/ata/ata-pci.h
  stable/8/sys/dev/ata/chipsets/ata-via.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/ata/ata-pci.h
==============================================================================
--- stable/8/sys/dev/ata/ata-pci.h	Thu Oct 29 10:03:08 2009	(r198575)
+++ stable/8/sys/dev/ata/ata-pci.h	Thu Oct 29 10:05:08 2009	(r198576)
@@ -415,6 +415,8 @@ struct ata_pci_controller {
 #define ATA_VIA8237             0x32271106
 #define ATA_VIA8237A            0x05911106
 #define ATA_VIA8237S		0x53371106
+#define ATA_VIA8237_5372	0x53721106
+#define ATA_VIA8237_7372	0x73721106
 #define ATA_VIA8251             0x33491106
 #define ATA_VIA8361             0x31121106
 #define ATA_VIA8363             0x03051106

Modified: stable/8/sys/dev/ata/chipsets/ata-via.c
==============================================================================
--- stable/8/sys/dev/ata/chipsets/ata-via.c	Thu Oct 29 10:03:08 2009	(r198575)
+++ stable/8/sys/dev/ata/chipsets/ata-via.c	Thu Oct 29 10:05:08 2009	(r198576)
@@ -95,6 +95,8 @@ ata_via_probe(device_t dev)
      { ATA_VIA8237,   0x00, VIA133, 0x00,    ATA_UDMA6, "8237" },
      { ATA_VIA8237A,  0x00, VIA133, 0x00,    ATA_UDMA6, "8237A" },
      { ATA_VIA8237S,  0x00, VIA133, 0x00,    ATA_UDMA6, "8237S" },
+     { ATA_VIA8237_5372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
+     { ATA_VIA8237_7372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
      { ATA_VIA8251,   0x00, VIA133, 0x00,    ATA_UDMA6, "8251" },
      { 0, 0, 0, 0, 0, 0 }};
     static struct ata_chip_id new_ids[] =
@@ -103,6 +105,8 @@ ata_via_probe(device_t dev)
      { ATA_VIA6421,   0x00, 6,      VIABAR,  ATA_SA150, "6421" },
      { ATA_VIA8237A,  0x00, 7,      0x00,    ATA_SA150, "8237A" },
      { ATA_VIA8237S,  0x00, 7,      0x00,    ATA_SA150, "8237S" },
+     { ATA_VIA8237_5372, 0x00, 7,   0x00,    ATA_SA300, "8237" },
+     { ATA_VIA8237_7372, 0x00, 7,   0x00,    ATA_SA300, "8237" },
      { ATA_VIA8251,   0x00, 0,      VIAAHCI, ATA_SA300, "8251" },
      { 0, 0, 0, 0, 0, 0 }};
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 10:35:51 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3C55B106566B;
	Thu, 29 Oct 2009 10:35:51 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 290058FC1C;
	Thu, 29 Oct 2009 10:35:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TAZojx091952;
	Thu, 29 Oct 2009 10:35:50 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TAZoVf091950;
	Thu, 29 Oct 2009 10:35:50 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910291035.n9TAZoVf091950@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 29 Oct 2009 10:35:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198577 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/ata dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 10:35:51 -0000

Author: mav
Date: Thu Oct 29 10:35:50 2009
New Revision: 198577
URL: http://svn.freebsd.org/changeset/base/198577

Log:
  MFC rev. 198488:
  Report SATA speeds to CAM, to not confuse users with low numbers logged.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/ata/atapi-cam.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/ata/atapi-cam.c
==============================================================================
--- stable/8/sys/dev/ata/atapi-cam.c	Thu Oct 29 10:05:08 2009	(r198576)
+++ stable/8/sys/dev/ata/atapi-cam.c	Thu Oct 29 10:35:50 2009	(r198577)
@@ -414,6 +414,12 @@ atapi_action(struct cam_sim *sim, union 
 	    case ATA_UDMA6:
 		cpi->base_transfer_speed = 133000;
 		break;
+	    case ATA_SA150:
+		cpi->base_transfer_speed = 150000;
+		break;
+	    case ATA_SA300:
+		cpi->base_transfer_speed = 300000;
+		break;
 	    default:
 		break;
 	    }

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 10:38:17 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C5565106568D;
	Thu, 29 Oct 2009 10:38:17 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B237E8FC0C;
	Thu, 29 Oct 2009 10:38:17 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TAcHDL092042;
	Thu, 29 Oct 2009 10:38:17 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TAcHdp092040;
	Thu, 29 Oct 2009 10:38:17 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910291038.n9TAcHdp092040@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 29 Oct 2009 10:38:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198578 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/ata dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 10:38:17 -0000

Author: mav
Date: Thu Oct 29 10:38:17 2009
New Revision: 198578
URL: http://svn.freebsd.org/changeset/base/198578

Log:
  MFC rev. 198487:
  Round timeout up when converting CAM milliseconds to ATA seconds.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/ata/atapi-cam.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/ata/atapi-cam.c
==============================================================================
--- stable/8/sys/dev/ata/atapi-cam.c	Thu Oct 29 10:35:50 2009	(r198577)
+++ stable/8/sys/dev/ata/atapi-cam.c	Thu Oct 29 10:38:17 2009	(r198578)
@@ -635,7 +635,7 @@ atapi_action(struct cam_sim *sim, union 
 	request->data = buf;
 	request->bytecount = len;
 	request->transfersize = min(request->bytecount, 65534);
-	request->timeout = ccb_h->timeout / 1000; /* XXX lost granularity */
+	request->timeout = (ccb_h->timeout + 999) / 1000;
 	request->callback = &atapi_cb;
 	request->flags = request_flags;
 
@@ -738,7 +738,7 @@ atapi_cb(struct ata_request *request)
 		request->data = (caddr_t)&csio->sense_data;
 		request->bytecount = sizeof(struct atapi_sense);
 		request->transfersize = min(request->bytecount, 65534);
-		request->timeout = csio->ccb_h.timeout / 1000;
+		request->timeout = (csio->ccb_h.timeout + 999) / 1000;
 		request->retries = 2;
 		request->flags = ATA_R_QUIET|ATA_R_ATAPI|ATA_R_IMMEDIATE;
 		hcb->flags |= AUTOSENSE;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 11:00:40 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3BB53106566C;
	Thu, 29 Oct 2009 11:00:40 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 297678FC2E;
	Thu, 29 Oct 2009 11:00:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TB0eCM093815;
	Thu, 29 Oct 2009 11:00:40 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TB0eIo093813;
	Thu, 29 Oct 2009 11:00:40 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <200910291100.n9TB0eIo093813@svn.freebsd.org>
From: Edwin Groothuis 
Date: Thu, 29 Oct 2009 11:00:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198579 - in stable/7/lib/libc: . stdtime
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 11:00:40 -0000

Author: edwin
Date: Thu Oct 29 11:00:39 2009
New Revision: 198579
URL: http://svn.freebsd.org/changeset/base/198579

Log:
  MFC of r197189
  
  Improve the way failure of pthread_key_create() gets detected.
  
  PR:           threads/138603
  Submitted by: Mikulas Patocka

Modified:
  stable/7/lib/libc/   (props changed)
  stable/7/lib/libc/stdtime/localtime.c

Modified: stable/7/lib/libc/stdtime/localtime.c
==============================================================================
--- stable/7/lib/libc/stdtime/localtime.c	Thu Oct 29 10:38:17 2009	(r198578)
+++ stable/7/lib/libc/stdtime/localtime.c	Thu Oct 29 11:00:39 2009	(r198579)
@@ -21,6 +21,7 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "private.h"
@@ -1413,12 +1414,15 @@ const time_t * const	timep;
 	static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER;
 	static pthread_key_t localtime_key = -1;
 	struct tm *p_tm;
+	int r;
 
 	if (__isthreaded != 0) {
 		_pthread_mutex_lock(&localtime_mutex);
 		if (localtime_key < 0) {
-			if (_pthread_key_create(&localtime_key, free) < 0) {
+			if ((r = _pthread_key_create(&localtime_key, free))
+			    != 0) {
 				_pthread_mutex_unlock(&localtime_mutex);
+				errno = r;
 				return(NULL);
 			}
 		}
@@ -1510,12 +1514,14 @@ const time_t * const	timep;
 	static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
 	static pthread_key_t gmtime_key = -1;
 	struct tm *p_tm;
+	int r;
 
 	if (__isthreaded != 0) {
 		_pthread_mutex_lock(&gmtime_mutex);
 		if (gmtime_key < 0) {
-			if (_pthread_key_create(&gmtime_key, free) < 0) {
+			if ((r = _pthread_key_create(&gmtime_key, free)) != 0) {
 				_pthread_mutex_unlock(&gmtime_mutex);
+				errno = r;
 				return(NULL);
 			}
 		}

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 13:41:05 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF791106566B;
	Thu, 29 Oct 2009 13:41:05 +0000 (UTC)
	(envelope-from emaste@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 935B48FC16;
	Thu, 29 Oct 2009 13:41:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TDf58H097868;
	Thu, 29 Oct 2009 13:41:05 GMT (envelope-from emaste@svn.freebsd.org)
Received: (from emaste@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TDf5aC097866;
	Thu, 29 Oct 2009 13:41:05 GMT (envelope-from emaste@svn.freebsd.org)
Message-Id: <200910291341.n9TDf5aC097866@svn.freebsd.org>
From: Ed Maste 
Date: Thu, 29 Oct 2009 13:41:05 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198584 - in stable/7/sys: . contrib/pf dev/aac
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 13:41:05 -0000

Author: emaste
Date: Thu Oct 29 13:41:05 2009
New Revision: 198584
URL: http://svn.freebsd.org/changeset/base/198584

Log:
  MFC r195614:
  
    Get correct maxio from the controller and drop the tunable.
    The default (64K) is too pessimistic for "new comm" hardware.
    Also, this is bad because multiple controllers get limited by
    the global tunable.
  
  At this point stable/7 and stable/8 are in sync, modulo KPI changes.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/aac/aac_disk.c

Modified: stable/7/sys/dev/aac/aac_disk.c
==============================================================================
--- stable/7/sys/dev/aac/aac_disk.c	Thu Oct 29 13:28:37 2009	(r198583)
+++ stable/7/sys/dev/aac/aac_disk.c	Thu Oct 29 13:41:05 2009	(r198584)
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -83,18 +82,8 @@ static driver_t aac_disk_driver = {
 	sizeof(struct aac_disk)
 };
 
-#define AAC_MAXIO	65536
-
 DRIVER_MODULE(aacd, aac, aac_disk_driver, aac_disk_devclass, 0, 0);
 
-/* sysctl tunables */
-static unsigned int aac_iosize_max = AAC_MAXIO;	/* due to limits of the card */
-TUNABLE_INT("hw.aac.iosize_max", &aac_iosize_max);
-
-SYSCTL_DECL(_hw_aac);
-SYSCTL_UINT(_hw_aac, OID_AUTO, iosize_max, CTLFLAG_RDTUN, &aac_iosize_max, 0,
-	    "Max I/O size per transfer to an array");
-
 /*
  * Handle open from generic layer.
  *
@@ -236,7 +225,7 @@ aac_dump_map_sg64(void *arg, bus_dma_seg
 /*
  * Dump memory out to an array
  *
- * Send out one command at a time with up to AAC_MAXIO of data.
+ * Send out one command at a time with up to maxio of data.
  */
 static int
 aac_disk_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length)
@@ -244,7 +233,7 @@ aac_disk_dump(void *arg, void *virtual, 
 	struct aac_disk *ad;
 	struct aac_softc *sc;
 	struct aac_fib *fib;
-	size_t len;
+	size_t len, maxio;
 	int size;
 	static bus_dmamap_t dump_datamap;
 	static int first = 0;
@@ -272,7 +261,8 @@ aac_disk_dump(void *arg, void *virtual, 
 	fib = &sc->aac_common->ac_sync_fib;
 
 	while (length > 0) {
-		len = (length > AAC_MAXIO) ? AAC_MAXIO : length;
+		maxio = sc->aac_max_sectors << 9;
+		len = (length > maxio) ? maxio : length;
 		if ((sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
 			struct aac_blockwrite *bw;
 			bw = (struct aac_blockwrite *)&fib->data[0];
@@ -408,7 +398,7 @@ aac_disk_attach(device_t dev)
 	sc->ad_disk = disk_alloc();
 	sc->ad_disk->d_drv1 = sc;
 	sc->ad_disk->d_name = "aacd";
-	sc->ad_disk->d_maxsize = aac_iosize_max;
+	sc->ad_disk->d_maxsize = sc->ad_controller->aac_max_sectors << 9;
 	sc->ad_disk->d_open = aac_disk_open;
 	sc->ad_disk->d_close = aac_disk_close;
 	sc->ad_disk->d_strategy = aac_disk_strategy;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 14:34:03 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2D72B1065670;
	Thu, 29 Oct 2009 14:34:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1951E8FC17;
	Thu, 29 Oct 2009 14:34:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TEY24V099349;
	Thu, 29 Oct 2009 14:34:02 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TEY2Sj099334;
	Thu, 29 Oct 2009 14:34:02 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291434.n9TEY2Sj099334@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 14:34:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198589 - in stable/7/sys: . amd64/amd64 amd64/include
	conf contrib/pf i386/i386 i386/include
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 14:34:03 -0000

Author: jhb
Date: Thu Oct 29 14:34:02 2009
New Revision: 198589
URL: http://svn.freebsd.org/changeset/base/198589

Log:
  MFC 192050, 192343, 192440:
  Implement simple machine check support for amd64 and i386.  It is disabled
  by default but can be enabled via the 'hw.mca.enabled' tunable.

Added:
  stable/7/sys/amd64/amd64/mca.c
     - copied, changed from r192050, head/sys/amd64/amd64/mca.c
  stable/7/sys/amd64/include/mca.h
     - copied unchanged from r192050, head/sys/amd64/include/mca.h
  stable/7/sys/i386/i386/mca.c
     - copied, changed from r192050, head/sys/i386/i386/mca.c
  stable/7/sys/i386/include/mca.h
     - copied unchanged from r192050, head/sys/i386/include/mca.h
Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/machdep.c
  stable/7/sys/amd64/amd64/mp_machdep.c
  stable/7/sys/amd64/amd64/trap.c
  stable/7/sys/amd64/include/specialreg.h
  stable/7/sys/conf/files.amd64
  stable/7/sys/conf/files.i386
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/i386/i386/machdep.c
  stable/7/sys/i386/i386/mp_machdep.c
  stable/7/sys/i386/i386/trap.c
  stable/7/sys/i386/include/specialreg.h

Modified: stable/7/sys/amd64/amd64/machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/machdep.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/amd64/amd64/machdep.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -109,6 +109,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -261,6 +262,7 @@ cpu_startup(dummy)
 	vm_pager_bufferinit();
 
 	cpu_setregs();
+	mca_init();
 }
 
 /*

Copied and modified: stable/7/sys/amd64/amd64/mca.c (from r192050, head/sys/amd64/amd64/mca.c)
==============================================================================
--- head/sys/amd64/amd64/mca.c	Wed May 13 17:53:04 2009	(r192050, copy source)
+++ stable/7/sys/amd64/amd64/mca.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -55,10 +55,15 @@ struct mca_internal {
 
 static MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture");
 
-static struct sysctl_oid *mca_sysctl_tree;
-
 static int mca_count;		/* Number of records stored. */
 
+SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD, NULL, "Machine Check Architecture");
+
+static int mca_enabled = 0;
+TUNABLE_INT("hw.mca.enabled", &mca_enabled);
+SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0,
+    "Administrative toggle for machine check support");
+
 static STAILQ_HEAD(, mca_internal) mca_records;
 static struct callout mca_timer;
 static int mca_ticks = 3600;	/* Check hourly by default. */
@@ -346,7 +351,7 @@ mca_scan(int mcip)
 
 	/* When handling a MCE#, treat the OVER flag as non-restartable. */
 	if (mcip)
-		ucmask = MC_STATUS_OVER;
+		ucmask |= MC_STATUS_OVER;
 	mcg_cap = rdmsr(MSR_MCG_CAP);
 	for (i = 0; i < (mcg_cap & MCG_CAP_COUNT); i++) {
 		rec = mca_record_entry(i);
@@ -426,7 +431,7 @@ static void
 mca_startup(void *dummy)
 {
 
-	if (!(cpu_feature & CPUID_MCA))
+	if (!mca_enabled || !(cpu_feature & CPUID_MCA))
 		return;
 
 	callout_reset(&mca_timer, mca_ticks * hz, mca_periodic_scan,
@@ -442,17 +447,15 @@ mca_setup(void)
 	STAILQ_INIT(&mca_records);
 	TASK_INIT(&mca_task, 0x8000, mca_scan_cpus, NULL);
 	callout_init(&mca_timer, CALLOUT_MPSAFE);
-	mca_sysctl_tree = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_hw),
-	    OID_AUTO, "mca", CTLFLAG_RW, NULL, "MCA container");
-	SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "count", CTLFLAG_RD, &mca_count, 0, "Record count");
-	SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "interval", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &mca_ticks,
 	    0, sysctl_mca_ticks, "I",
 	    "Periodic interval in seconds to scan for machine checks");
-	SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "records", CTLFLAG_RD, sysctl_mca_records, "Machine check records");
-	SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "force_scan", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0,
 	    sysctl_mca_scan, "I", "Force an immediate scan for machine checks");
 }
@@ -465,7 +468,7 @@ mca_init(void)
 	int i;
 
 	/* MCE is required. */
-	if (!(cpu_feature & CPUID_MCE))
+	if (!mca_enabled || !(cpu_feature & CPUID_MCE))
 		return;
 
 	if (cpu_feature & CPUID_MCA) {
@@ -488,10 +491,6 @@ mca_init(void)
 			if (!(i == 0 && (cpu_id & 0xf00) == 0x600))
 				wrmsr(MSR_MC_CTL(i), 0xffffffffffffffffUL);
 
-			/* XXX: Better CPU test needed here. */
-			if ((cpu_id & 0xf00) == 0xf00)
-				mca_record_entry(i);
-
 			/* Clear all errors. */
 			wrmsr(MSR_MC_STATUS(i), 0);
 		}

Modified: stable/7/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/mp_machdep.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/amd64/amd64/mp_machdep.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -562,6 +563,8 @@ init_secondary(void)
 	KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread"));
 	PCPU_SET(curthread, PCPU_GET(idlethread));
 
+	mca_init();
+
 	mtx_lock_spin(&ap_boot_mtx);
 
 	/* Init local apic for irq's */

Modified: stable/7/sys/amd64/amd64/trap.c
==============================================================================
--- stable/7/sys/amd64/amd64/trap.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/amd64/amd64/trap.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #ifdef SMP
@@ -228,6 +229,12 @@ trap(struct trapframe *frame)
 		goto out;
 #endif
 
+	if (type == T_MCHK) {
+		if (!mca_intr())
+			trap_fatal(frame, 0);
+		goto out;
+	}
+
 #ifdef KDTRACE_HOOKS
 	/*
 	 * A trap can occur while DTrace executes a probe. Before

Copied: stable/7/sys/amd64/include/mca.h (from r192050, head/sys/amd64/include/mca.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/7/sys/amd64/include/mca.h	Thu Oct 29 14:34:02 2009	(r198589, copy of r192050, head/sys/amd64/include/mca.h)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2009 Advanced Computing Technologies LLC
+ * Written by: John H. Baldwin 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __MACHINE_MCA_H__
+#define	__MACHINE_MCA_H__
+
+struct mca_record {
+	uint64_t	mr_status;
+	uint64_t	mr_addr;
+	uint64_t	mr_misc;
+	uint64_t	mr_tsc;
+	int		mr_apic_id;
+};
+
+#ifdef _KERNEL
+
+void	mca_init(void);
+int	mca_intr(void);
+
+#endif
+
+#endif /* !__MACHINE_MCA_H__ */

Modified: stable/7/sys/amd64/include/specialreg.h
==============================================================================
--- stable/7/sys/amd64/include/specialreg.h	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/amd64/include/specialreg.h	Thu Oct 29 14:34:02 2009	(r198589)
@@ -339,6 +339,34 @@
 #define	DIR1			0xff
 
 /*
+ * Machine Check register constants.
+ */
+#define	MCG_CAP_COUNT		0x000000ff
+#define	MCG_CAP_CTL_P		0x00000100
+#define	MCG_CAP_EXT_P		0x00000200
+#define	MCG_CAP_TES_P		0x00000800
+#define	MCG_CAP_EXT_CNT		0x00ff0000
+#define	MCG_STATUS_RIPV		0x00000001
+#define	MCG_STATUS_EIPV		0x00000002
+#define	MCG_STATUS_MCIP		0x00000004
+#define	MCG_CTL_ENABLE		0xffffffffffffffffUL
+#define	MCG_CTL_DISABLE		0x0000000000000000UL
+#define	MSR_MC_CTL(x)		(MSR_MC0_CTL + (x) * 4)
+#define	MSR_MC_STATUS(x)	(MSR_MC0_STATUS + (x) * 4)
+#define	MSR_MC_ADDR(x)		(MSR_MC0_ADDR + (x) * 4)
+#define	MSR_MC_MISC(x)		(MSR_MC0_MISC + (x) * 4)
+#define	MC_STATUS_MCA_ERROR	0x000000000000ffffUL
+#define	MC_STATUS_MODEL_ERROR	0x00000000ffff0000UL
+#define	MC_STATUS_OTHER_INFO	0x01ffffff00000000UL
+#define	MC_STATUS_PCC		0x0200000000000000UL
+#define	MC_STATUS_ADDRV		0x0400000000000000UL
+#define	MC_STATUS_MISCV		0x0800000000000000UL
+#define	MC_STATUS_EN		0x1000000000000000UL
+#define	MC_STATUS_UC		0x2000000000000000UL
+#define	MC_STATUS_OVER		0x4000000000000000UL
+#define	MC_STATUS_VAL		0x8000000000000000UL
+
+/*
  * The following four 3-byte registers control the non-cacheable regions.
  * These registers must be written as three separate bytes.
  *

Modified: stable/7/sys/conf/files.amd64
==============================================================================
--- stable/7/sys/conf/files.amd64	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/conf/files.amd64	Thu Oct 29 14:34:02 2009	(r198589)
@@ -99,6 +99,7 @@ amd64/amd64/legacy.c		standard
 amd64/amd64/local_apic.c	standard
 amd64/amd64/locore.S		standard	no-obj
 amd64/amd64/machdep.c		standard
+amd64/amd64/mca.c		standard
 amd64/amd64/mem.c		optional	mem
 amd64/amd64/minidump_machdep.c	standard
 amd64/amd64/mp_machdep.c	optional	smp

Modified: stable/7/sys/conf/files.i386
==============================================================================
--- stable/7/sys/conf/files.i386	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/conf/files.i386	Thu Oct 29 14:34:02 2009	(r198589)
@@ -282,6 +282,7 @@ i386/i386/local_apic.c		optional apic
 i386/i386/locore.s		standard	no-obj
 i386/i386/longrun.c		optional cpu_enable_longrun
 i386/i386/machdep.c		standard
+i386/i386/mca.c			standard
 i386/i386/mem.c			optional mem
 i386/i386/minidump_machdep.c	standard
 i386/i386/mp_clock.c		optional smp

Modified: stable/7/sys/i386/i386/machdep.c
==============================================================================
--- stable/7/sys/i386/i386/machdep.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/i386/i386/machdep.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -114,6 +114,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -290,6 +291,7 @@ cpu_startup(dummy)
 	vm_pager_bufferinit();
 
 	cpu_setregs();
+	mca_init();
 }
 
 /*

Copied and modified: stable/7/sys/i386/i386/mca.c (from r192050, head/sys/i386/i386/mca.c)
==============================================================================
--- head/sys/i386/i386/mca.c	Wed May 13 17:53:04 2009	(r192050, copy source)
+++ stable/7/sys/i386/i386/mca.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -55,10 +55,15 @@ struct mca_internal {
 
 static MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture");
 
-static struct sysctl_oid *mca_sysctl_tree;
-
 static int mca_count;		/* Number of records stored. */
 
+SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD, NULL, "Machine Check Architecture");
+
+static int mca_enabled = 0;
+TUNABLE_INT("hw.mca.enabled", &mca_enabled);
+SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0,
+    "Administrative toggle for machine check support");
+
 static STAILQ_HEAD(, mca_internal) mca_records;
 static struct callout mca_timer;
 static int mca_ticks = 3600;	/* Check hourly by default. */
@@ -346,7 +351,7 @@ mca_scan(int mcip)
 
 	/* When handling a MCE#, treat the OVER flag as non-restartable. */
 	if (mcip)
-		ucmask = MC_STATUS_OVER;
+		ucmask |= MC_STATUS_OVER;
 	mcg_cap = rdmsr(MSR_MCG_CAP);
 	for (i = 0; i < (mcg_cap & MCG_CAP_COUNT); i++) {
 		rec = mca_record_entry(i);
@@ -426,7 +431,7 @@ static void
 mca_startup(void *dummy)
 {
 
-	if (!(cpu_feature & CPUID_MCA))
+	if (!mca_enabled || !(cpu_feature & CPUID_MCA))
 		return;
 
 	callout_reset(&mca_timer, mca_ticks * hz, mca_periodic_scan,
@@ -442,17 +447,15 @@ mca_setup(void)
 	STAILQ_INIT(&mca_records);
 	TASK_INIT(&mca_task, 0x8000, mca_scan_cpus, NULL);
 	callout_init(&mca_timer, CALLOUT_MPSAFE);
-	mca_sysctl_tree = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_hw),
-	    OID_AUTO, "mca", CTLFLAG_RW, NULL, "MCA container");
-	SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "count", CTLFLAG_RD, &mca_count, 0, "Record count");
-	SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "interval", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &mca_ticks,
 	    0, sysctl_mca_ticks, "I",
 	    "Periodic interval in seconds to scan for machine checks");
-	SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "records", CTLFLAG_RD, sysctl_mca_records, "Machine check records");
-	SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(mca_sysctl_tree), OID_AUTO,
+	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "force_scan", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0,
 	    sysctl_mca_scan, "I", "Force an immediate scan for machine checks");
 }
@@ -465,7 +468,7 @@ mca_init(void)
 	int i;
 
 	/* MCE is required. */
-	if (!(cpu_feature & CPUID_MCE))
+	if (!mca_enabled || !(cpu_feature & CPUID_MCE))
 		return;
 
 	if (cpu_feature & CPUID_MCA) {
@@ -488,10 +491,6 @@ mca_init(void)
 			if (!(i == 0 && (cpu_id & 0xf00) == 0x600))
 				wrmsr(MSR_MC_CTL(i), 0xffffffffffffffffUL);
 
-			/* XXX: Better CPU test needed here. */
-			if ((cpu_id & 0xf00) == 0xf00)
-				mca_record_entry(i);
-
 			/* Clear all errors. */
 			wrmsr(MSR_MC_STATUS(i), 0);
 		}

Modified: stable/7/sys/i386/i386/mp_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/mp_machdep.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/i386/i386/mp_machdep.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -612,6 +613,8 @@ init_secondary(void)
 	KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread"));
 	PCPU_SET(curthread, PCPU_GET(idlethread));
 
+	mca_init();
+
 	mtx_lock_spin(&ap_boot_mtx);
 
 	/* Init local apic for irq's */

Modified: stable/7/sys/i386/i386/trap.c
==============================================================================
--- stable/7/sys/i386/i386/trap.c	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/i386/i386/trap.c	Thu Oct 29 14:34:02 2009	(r198589)
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #ifdef SMP
@@ -242,6 +243,12 @@ trap(struct trapframe *frame)
 	    goto out;
 #endif
 
+	if (type == T_MCHK) {
+		if (!mca_intr())
+			trap_fatal(frame, 0);
+		goto out;
+	}
+
 #ifdef KDTRACE_HOOKS
 	/*
 	 * A trap can occur while DTrace executes a probe. Before

Copied: stable/7/sys/i386/include/mca.h (from r192050, head/sys/i386/include/mca.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/7/sys/i386/include/mca.h	Thu Oct 29 14:34:02 2009	(r198589, copy of r192050, head/sys/i386/include/mca.h)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2009 Advanced Computing Technologies LLC
+ * Written by: John H. Baldwin 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __MACHINE_MCA_H__
+#define	__MACHINE_MCA_H__
+
+struct mca_record {
+	uint64_t	mr_status;
+	uint64_t	mr_addr;
+	uint64_t	mr_misc;
+	uint64_t	mr_tsc;
+	int		mr_apic_id;
+};
+
+#ifdef _KERNEL
+
+void	mca_init(void);
+int	mca_intr(void);
+
+#endif
+
+#endif /* !__MACHINE_MCA_H__ */

Modified: stable/7/sys/i386/include/specialreg.h
==============================================================================
--- stable/7/sys/i386/include/specialreg.h	Thu Oct 29 14:22:09 2009	(r198588)
+++ stable/7/sys/i386/include/specialreg.h	Thu Oct 29 14:34:02 2009	(r198589)
@@ -408,6 +408,34 @@
 #define	DIR1			0xff
 
 /*
+ * Machine Check register constants.
+ */
+#define	MCG_CAP_COUNT		0x000000ff
+#define	MCG_CAP_CTL_P		0x00000100
+#define	MCG_CAP_EXT_P		0x00000200
+#define	MCG_CAP_TES_P		0x00000800
+#define	MCG_CAP_EXT_CNT		0x00ff0000
+#define	MCG_STATUS_RIPV		0x00000001
+#define	MCG_STATUS_EIPV		0x00000002
+#define	MCG_STATUS_MCIP		0x00000004
+#define	MCG_CTL_ENABLE		0xffffffffffffffffUL
+#define	MCG_CTL_DISABLE		0x0000000000000000UL
+#define	MSR_MC_CTL(x)		(MSR_MC0_CTL + (x) * 4)
+#define	MSR_MC_STATUS(x)	(MSR_MC0_STATUS + (x) * 4)
+#define	MSR_MC_ADDR(x)		(MSR_MC0_ADDR + (x) * 4)
+#define	MSR_MC_MISC(x)		(MSR_MC0_MISC + (x) * 4)
+#define	MC_STATUS_MCA_ERROR	0x000000000000ffffUL
+#define	MC_STATUS_MODEL_ERROR	0x00000000ffff0000UL
+#define	MC_STATUS_OTHER_INFO	0x01ffffff00000000UL
+#define	MC_STATUS_PCC		0x0200000000000000UL
+#define	MC_STATUS_ADDRV		0x0400000000000000UL
+#define	MC_STATUS_MISCV		0x0800000000000000UL
+#define	MC_STATUS_EN		0x1000000000000000UL
+#define	MC_STATUS_UC		0x2000000000000000UL
+#define	MC_STATUS_OVER		0x4000000000000000UL
+#define	MC_STATUS_VAL		0x8000000000000000UL
+
+/*
  * The following four 3-byte registers control the non-cacheable regions.
  * These registers must be written as three separate bytes.
  *

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 14:40:21 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4B7C3106566C;
	Thu, 29 Oct 2009 14:40:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 389588FC08;
	Thu, 29 Oct 2009 14:40:21 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TEeL9q099562;
	Thu, 29 Oct 2009 14:40:21 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TEeLL2099559;
	Thu, 29 Oct 2009 14:40:21 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291440.n9TEeLL2099559@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 14:40:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198591 - in stable/8/usr.sbin/acpi: . acpidump
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 14:40:21 -0000

Author: jhb
Date: Thu Oct 29 14:40:21 2009
New Revision: 198591
URL: http://svn.freebsd.org/changeset/base/198591

Log:
  MFC 196555:
  - Use the headers from ACPI-CA to define various constants and structures
    for table layouts, etc. rather than homerolling our own structures and
    constants in acpidump.h.
  - Verify the extended checksum on the RSDP.
  - Handle new ACPI 3.0 fields in MADT including X2APIC entries and
    UIDs for local SAPICs.
  - Add handling for new ACPI 3.0 flags in the FADT.

Modified:
  stable/8/usr.sbin/acpi/   (props changed)
  stable/8/usr.sbin/acpi/acpidump/acpi.c
  stable/8/usr.sbin/acpi/acpidump/acpi_user.c
  stable/8/usr.sbin/acpi/acpidump/acpidump.c
  stable/8/usr.sbin/acpi/acpidump/acpidump.h

Modified: stable/8/usr.sbin/acpi/acpidump/acpi.c
==============================================================================
--- stable/8/usr.sbin/acpi/acpidump/acpi.c	Thu Oct 29 14:34:24 2009	(r198590)
+++ stable/8/usr.sbin/acpi/acpidump/acpi.c	Thu Oct 29 14:40:21 2009	(r198591)
@@ -47,31 +47,36 @@
 #define END_COMMENT	" */\n"
 
 static void	acpi_print_string(char *s, size_t length);
-static void	acpi_print_gas(struct ACPIgas *gas);
-static int	acpi_get_fadt_revision(struct FADTbody *fadt);
-static void	acpi_handle_fadt(struct ACPIsdt *fadt);
+static void	acpi_print_gas(ACPI_GENERIC_ADDRESS *gas);
+static int	acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt);
+static void	acpi_handle_fadt(ACPI_TABLE_HEADER *fadt);
 static void	acpi_print_cpu(u_char cpu_id);
-static void	acpi_print_local_apic(u_char cpu_id, u_char apic_id,
-				      u_int32_t flags);
-static void	acpi_print_io_apic(u_char apic_id, u_int32_t int_base,
-				   u_int64_t apic_addr);
-static void	acpi_print_mps_flags(u_int16_t flags);
-static void	acpi_print_intr(u_int32_t intr, u_int16_t mps_flags);
-static void	acpi_print_apic(struct MADT_APIC *mp);
-static void	acpi_handle_apic(struct ACPIsdt *sdp);
-static void	acpi_handle_hpet(struct ACPIsdt *sdp);
+static void	acpi_print_cpu_uid(uint32_t uid, char *uid_string);
+static void	acpi_print_local_apic(uint32_t apic_id, uint32_t flags);
+static void	acpi_print_io_apic(uint32_t apic_id, uint32_t int_base,
+		    uint64_t apic_addr);
+static void	acpi_print_mps_flags(uint16_t flags);
+static void	acpi_print_intr(uint32_t intr, uint16_t mps_flags);
+static void	acpi_print_local_nmi(u_int lint, uint16_t mps_flags);
+static void	acpi_print_madt(ACPI_SUBTABLE_HEADER *mp);
+static void	acpi_handle_madt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_hpet(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp);
 static void	acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain,
 		    uint32_t flags);
-static void	acpi_print_srat_memory(struct SRAT_memory *mp);
-static void	acpi_print_srat(struct SRATentry *srat);
-static void	acpi_handle_srat(struct ACPIsdt *sdp);
-static void	acpi_print_sdt(struct ACPIsdt *sdp);
-static void	acpi_print_fadt(struct ACPIsdt *sdp);
-static void	acpi_print_facs(struct FACSbody *facs);
-static void	acpi_print_dsdt(struct ACPIsdt *dsdp);
-static struct ACPIsdt *acpi_map_sdt(vm_offset_t pa);
-static void	acpi_print_rsd_ptr(struct ACPIrsdp *rp);
-static void	acpi_handle_rsdt(struct ACPIsdt *rsdp);
+static void	acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp);
+static void	acpi_print_srat(ACPI_SUBTABLE_HEADER *srat);
+static void	acpi_handle_srat(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_sdt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_fadt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_facs(ACPI_TABLE_FACS *facs);
+static void	acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp);
+static ACPI_TABLE_HEADER *acpi_map_sdt(vm_offset_t pa);
+static void	acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp);
+static void	acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp);
+static void	acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first,
+		    void (*action)(ACPI_SUBTABLE_HEADER *));
 
 /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */
 static int addr_size;
@@ -92,41 +97,44 @@ acpi_print_string(char *s, size_t length
 }
 
 static void
-acpi_print_gas(struct ACPIgas *gas)
+acpi_print_gas(ACPI_GENERIC_ADDRESS *gas)
 {
-	switch(gas->address_space_id) {
+	switch(gas->SpaceId) {
 	case ACPI_GAS_MEMORY:
-		printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_IO:
-		printf("0x%02lx:%u[%u] (IO)", (u_long)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%02lx:%u[%u] (IO)", (u_long)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_PCI:
-		printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->address >> 32),
-		       (uint16_t)((gas->address >> 16) & 0xffff),
-		       (uint16_t)gas->address);
+		printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->Address >> 32),
+		       (uint16_t)((gas->Address >> 16) & 0xffff),
+		       (uint16_t)gas->Address);
 		break;
 	/* XXX How to handle these below? */
 	case ACPI_GAS_EMBEDDED:
-		printf("0x%x:%u[%u] (EC)", (uint16_t)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%x:%u[%u] (EC)", (uint16_t)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_SMBUS:
-		printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
+	case ACPI_GAS_CMOS:
+	case ACPI_GAS_PCIBAR:
+	case ACPI_GAS_DATATABLE:
 	case ACPI_GAS_FIXED:
 	default:
-		printf("0x%08lx (?)", (u_long)gas->address);
+		printf("0x%08lx (?)", (u_long)gas->Address);
 		break;
 	}
 }
 
 /* The FADT revision indicates whether we use the DSDT or X_DSDT addresses. */
 static int
-acpi_get_fadt_revision(struct FADTbody *fadt)
+acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt)
 {
 	int fadt_revision;
 
@@ -141,8 +149,8 @@ acpi_get_fadt_revision(struct FADTbody *
 		 * 32 and 64 bit versions don't match, prefer the 32 bit
 		 * version for all subsequent tables.
 		 */
-		if (fadt->facs_ptr != 0 &&
-		    (fadt->x_facs_ptr & 0xffffffff) != fadt->facs_ptr)
+		if (fadt->Facs != 0 &&
+		    (fadt->XFacs & 0xffffffff) != fadt->Facs)
 			fadt_revision = 1;
 	} else
 		fadt_revision = 1;
@@ -150,35 +158,52 @@ acpi_get_fadt_revision(struct FADTbody *
 }
 
 static void
-acpi_handle_fadt(struct ACPIsdt *sdp)
+acpi_handle_fadt(ACPI_TABLE_HEADER *sdp)
 {
-	struct ACPIsdt	*dsdp;
-	struct FACSbody	*facs;
-	struct FADTbody *fadt;
+	ACPI_TABLE_HEADER *dsdp;
+	ACPI_TABLE_FACS	*facs;
+	ACPI_TABLE_FADT *fadt;
 	int		fadt_revision;
 
-	fadt = (struct FADTbody *)sdp->body;
+	fadt = (ACPI_TABLE_FADT *)sdp;
 	acpi_print_fadt(sdp);
 
 	fadt_revision = acpi_get_fadt_revision(fadt);
 	if (fadt_revision == 1)
-		facs = (struct FACSbody *)acpi_map_sdt(fadt->facs_ptr);
+		facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs);
 	else
-		facs = (struct FACSbody *)acpi_map_sdt(fadt->x_facs_ptr);
-	if (memcmp(facs->signature, "FACS", 4) != 0 || facs->len < 64)
+		facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs);
+	if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)
 		errx(1, "FACS is corrupt");
 	acpi_print_facs(facs);
 
 	if (fadt_revision == 1)
-		dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr);
+		dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt);
 	else
-		dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr);
-	if (acpi_checksum(dsdp, dsdp->len))
+		dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt);
+	if (acpi_checksum(dsdp, dsdp->Length))
 		errx(1, "DSDT is corrupt");
 	acpi_print_dsdt(dsdp);
 }
 
 static void
+acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first,
+    void (*action)(ACPI_SUBTABLE_HEADER *))
+{
+	ACPI_SUBTABLE_HEADER *subtable;
+	char *end;
+
+	subtable = first;
+	end = (char *)table + table->Length;
+	while ((char *)subtable < end) {
+		printf("\n");
+		action(subtable);
+		subtable = (ACPI_SUBTABLE_HEADER *)((char *)subtable +
+		    subtable->Length);
+	}
+}
+
+static void
 acpi_print_cpu(u_char cpu_id)
 {
 
@@ -190,219 +215,264 @@ acpi_print_cpu(u_char cpu_id)
 }
 
 static void
-acpi_print_local_apic(u_char cpu_id, u_char apic_id, u_int32_t flags)
+acpi_print_cpu_uid(uint32_t uid, char *uid_string)
 {
-	acpi_print_cpu(cpu_id);
+
+	printf("\tUID=%d", uid);
+	if (uid_string != NULL)
+		printf(" (%s)", uid_string);
+	printf("\n");
+}
+
+static void
+acpi_print_local_apic(uint32_t apic_id, uint32_t flags)
+{
+
 	printf("\tFlags={");
-	if (flags & ACPI_MADT_APIC_LOCAL_FLAG_ENABLED)
+	if (flags & ACPI_MADT_ENABLED)
 		printf("ENABLED");
 	else
 		printf("DISABLED");
 	printf("}\n");
-	printf("\tAPIC ID=%d\n", (u_int)apic_id);
+	printf("\tAPIC ID=%d\n", apic_id);
 }
 
 static void
-acpi_print_io_apic(u_char apic_id, u_int32_t int_base, u_int64_t apic_addr)
+acpi_print_io_apic(uint32_t apic_id, uint32_t int_base, uint64_t apic_addr)
 {
-	printf("\tAPIC ID=%d\n", (u_int)apic_id);
+
+	printf("\tAPIC ID=%d\n", apic_id);
 	printf("\tINT BASE=%d\n", int_base);
-	printf("\tADDR=0x%016jx\n", apic_addr);
+	printf("\tADDR=0x%016jx\n", (uintmax_t)apic_addr);
 }
 
 static void
-acpi_print_mps_flags(u_int16_t flags)
+acpi_print_mps_flags(uint16_t flags)
 {
 
 	printf("\tFlags={Polarity=");
-	switch (flags & MPS_INT_FLAG_POLARITY_MASK) {
-	case MPS_INT_FLAG_POLARITY_CONFORM:
+	switch (flags & ACPI_MADT_POLARITY_MASK) {
+	case ACPI_MADT_POLARITY_CONFORMS:
 		printf("conforming");
 		break;
-	case MPS_INT_FLAG_POLARITY_HIGH:
+	case ACPI_MADT_POLARITY_ACTIVE_HIGH:
 		printf("active-hi");
 		break;
-	case MPS_INT_FLAG_POLARITY_LOW:
+	case ACPI_MADT_POLARITY_ACTIVE_LOW:
 		printf("active-lo");
 		break;
 	default:
-		printf("0x%x", flags & MPS_INT_FLAG_POLARITY_MASK);
+		printf("0x%x", flags & ACPI_MADT_POLARITY_MASK);
 		break;
 	}
 	printf(", Trigger=");
-	switch (flags & MPS_INT_FLAG_TRIGGER_MASK) {
-	case MPS_INT_FLAG_TRIGGER_CONFORM:
+	switch (flags & ACPI_MADT_TRIGGER_MASK) {
+	case ACPI_MADT_TRIGGER_CONFORMS:
 		printf("conforming");
 		break;
-	case MPS_INT_FLAG_TRIGGER_EDGE:
+	case ACPI_MADT_TRIGGER_EDGE:
 		printf("edge");
 		break;
-	case MPS_INT_FLAG_TRIGGER_LEVEL:
+	case ACPI_MADT_TRIGGER_LEVEL:
 		printf("level");
 		break;
 	default:
-		printf("0x%x", (flags & MPS_INT_FLAG_TRIGGER_MASK) >> 2);
+		printf("0x%x", (flags & ACPI_MADT_TRIGGER_MASK) >> 2);
 	}
 	printf("}\n");
 }
 
 static void
-acpi_print_intr(u_int32_t intr, u_int16_t mps_flags)
+acpi_print_intr(uint32_t intr, uint16_t mps_flags)
 {
 
-	printf("\tINTR=%d\n", (u_int)intr);
+	printf("\tINTR=%d\n", intr);
+	acpi_print_mps_flags(mps_flags);
+}
+
+static void
+acpi_print_local_nmi(u_int lint, uint16_t mps_flags)
+{
+
+	printf("\tLINT Pin=%d\n", lint);
 	acpi_print_mps_flags(mps_flags);
 }
 
 const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI",
-			     "Local NMI", "Local APIC Override", "IO SAPIC",
-			     "Local SAPIC", "Platform Interrupt" };
-const char *platform_int_types[] = { "PMI", "INIT",
+			     "Local APIC NMI", "Local APIC Override",
+			     "IO SAPIC", "Local SAPIC", "Platform Interrupt",
+			     "Local X2APIC", "Local X2APIC NMI" };
+const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT",
 				     "Corrected Platform Error" };
 
 static void
-acpi_print_apic(struct MADT_APIC *mp)
+acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
 {
+	ACPI_MADT_LOCAL_APIC *lapic;
+	ACPI_MADT_IO_APIC *ioapic;
+	ACPI_MADT_INTERRUPT_OVERRIDE *over;
+	ACPI_MADT_NMI_SOURCE *nmi;
+	ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi;
+	ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic_over;
+	ACPI_MADT_IO_SAPIC *iosapic;
+	ACPI_MADT_LOCAL_SAPIC *lsapic;
+	ACPI_MADT_INTERRUPT_SOURCE *isrc;
+	ACPI_MADT_LOCAL_X2APIC *x2apic;
+	ACPI_MADT_LOCAL_X2APIC_NMI *x2apic_nmi;
 
-	if (mp->type < sizeof(apic_types) / sizeof(apic_types[0]))
-		printf("\tType=%s\n", apic_types[mp->type]);
+	if (mp->Type < sizeof(apic_types) / sizeof(apic_types[0]))
+		printf("\tType=%s\n", apic_types[mp->Type]);
 	else
-		printf("\tType=%d (unknown)\n", mp->type);
-	switch (mp->type) {
-	case ACPI_MADT_APIC_TYPE_LOCAL_APIC:
-		acpi_print_local_apic(mp->body.local_apic.cpu_id,
-		    mp->body.local_apic.apic_id, mp->body.local_apic.flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_IO_APIC:
-		acpi_print_io_apic(mp->body.io_apic.apic_id,
-		    mp->body.io_apic.int_base,
-		    mp->body.io_apic.apic_addr);
-		break;
-	case ACPI_MADT_APIC_TYPE_INT_OVERRIDE:
-		printf("\tBUS=%d\n", (u_int)mp->body.int_override.bus);
-		printf("\tIRQ=%d\n", (u_int)mp->body.int_override.source);
-		acpi_print_intr(mp->body.int_override.intr,
-		    mp->body.int_override.mps_flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_NMI:
-		acpi_print_intr(mp->body.nmi.intr, mp->body.nmi.mps_flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_NMI:
-		acpi_print_cpu(mp->body.local_nmi.cpu_id);
-		printf("\tLINT Pin=%d\n", mp->body.local_nmi.lintpin);
-		acpi_print_mps_flags(mp->body.local_nmi.mps_flags);
+		printf("\tType=%d (unknown)\n", mp->Type);
+	switch (mp->Type) {
+	case ACPI_MADT_TYPE_LOCAL_APIC:
+		lapic = (ACPI_MADT_LOCAL_APIC *)mp;
+		acpi_print_cpu(lapic->ProcessorId);
+		acpi_print_local_apic(lapic->Id, lapic->LapicFlags);
+		break;
+	case ACPI_MADT_TYPE_IO_APIC:
+		ioapic = (ACPI_MADT_IO_APIC *)mp;
+		acpi_print_io_apic(ioapic->Id, ioapic->GlobalIrqBase,
+		    ioapic->Address);
+		break;
+	case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
+		over = (ACPI_MADT_INTERRUPT_OVERRIDE *)mp;
+		printf("\tBUS=%d\n", (u_int)over->Bus);
+		printf("\tIRQ=%d\n", (u_int)over->SourceIrq);
+		acpi_print_intr(over->GlobalIrq, over->IntiFlags);
+		break;
+	case ACPI_MADT_TYPE_NMI_SOURCE:
+		nmi = (ACPI_MADT_NMI_SOURCE *)mp;
+		acpi_print_intr(nmi->GlobalIrq, nmi->IntiFlags);
+		break;
+	case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
+		lapic_nmi = (ACPI_MADT_LOCAL_APIC_NMI *)mp;
+		acpi_print_cpu(lapic_nmi->ProcessorId);
+		acpi_print_local_nmi(lapic_nmi->Lint, lapic_nmi->IntiFlags);
 		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE:
+	case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
+		lapic_over = (ACPI_MADT_LOCAL_APIC_OVERRIDE *)mp;
 		printf("\tLocal APIC ADDR=0x%016jx\n",
-		    mp->body.local_apic_override.apic_addr);
-		break;
-	case ACPI_MADT_APIC_TYPE_IO_SAPIC:
-		acpi_print_io_apic(mp->body.io_sapic.apic_id,
-		    mp->body.io_sapic.int_base,
-		    mp->body.io_sapic.apic_addr);
-		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_SAPIC:
-		acpi_print_local_apic(mp->body.local_sapic.cpu_id,
-		    mp->body.local_sapic.apic_id, mp->body.local_sapic.flags);
-		printf("\tAPIC EID=%d\n", (u_int)mp->body.local_sapic.apic_eid);
+		    (uintmax_t)lapic_over->Address);
 		break;
-	case ACPI_MADT_APIC_TYPE_INT_SRC:
-		printf("\tType=%s\n",
-		    platform_int_types[mp->body.int_src.type]);
-		printf("\tCPU ID=%d\n", (u_int)mp->body.int_src.cpu_id);
-		printf("\tCPU EID=%d\n", (u_int)mp->body.int_src.cpu_id);
-		printf("\tSAPIC Vector=%d\n",
-		    (u_int)mp->body.int_src.sapic_vector);
-		acpi_print_intr(mp->body.int_src.intr,
-		    mp->body.int_src.mps_flags);
+	case ACPI_MADT_TYPE_IO_SAPIC:
+		iosapic = (ACPI_MADT_IO_SAPIC *)mp;
+		acpi_print_io_apic(iosapic->Id, iosapic->GlobalIrqBase,
+		    iosapic->Address);
+		break;
+	case ACPI_MADT_TYPE_LOCAL_SAPIC:
+		lsapic = (ACPI_MADT_LOCAL_SAPIC *)mp;
+		acpi_print_cpu(lsapic->ProcessorId);
+		acpi_print_local_apic(lsapic->Id, lsapic->LapicFlags);
+		printf("\tAPIC EID=%d\n", (u_int)lsapic->Eid);
+		if (mp->Length > __offsetof(ACPI_MADT_LOCAL_SAPIC, Uid))
+			acpi_print_cpu_uid(lsapic->Uid, lsapic->UidString);
+		break;
+	case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
+		isrc = (ACPI_MADT_INTERRUPT_SOURCE *)mp;
+		if (isrc->Type < sizeof(platform_int_types) /
+		    sizeof(platform_int_types[0]))
+			printf("\tType=%s\n", platform_int_types[isrc->Type]);
+		else
+			printf("\tType=%d (unknown)\n", isrc->Type);
+		printf("\tAPIC ID=%d\n", (u_int)isrc->Id);
+		printf("\tAPIC EID=%d\n", (u_int)isrc->Eid);
+		printf("\tSAPIC Vector=%d\n", (u_int)isrc->IoSapicVector);
+		acpi_print_intr(isrc->GlobalIrq, isrc->IntiFlags);
+		break;
+	case ACPI_MADT_TYPE_LOCAL_X2APIC:
+		x2apic = (ACPI_MADT_LOCAL_X2APIC *)mp;
+		acpi_print_cpu_uid(x2apic->Uid, NULL);
+		acpi_print_local_apic(x2apic->LocalApicId, x2apic->LapicFlags);
+		break;
+	case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
+		x2apic_nmi = (ACPI_MADT_LOCAL_X2APIC_NMI *)mp;
+		acpi_print_cpu_uid(x2apic_nmi->Uid, NULL);
+		acpi_print_local_nmi(x2apic_nmi->Lint, x2apic_nmi->IntiFlags);
 		break;
 	}
 }
 
 static void
-acpi_handle_apic(struct ACPIsdt *sdp)
+acpi_handle_madt(ACPI_TABLE_HEADER *sdp)
 {
-	struct MADTbody *madtp;
-	struct MADT_APIC *madt_apicp;
+	ACPI_TABLE_MADT *madt;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	madtp = (struct MADTbody *) sdp->body;
-	printf("\tLocal APIC ADDR=0x%08x\n", madtp->lapic_addr);
+	madt = (ACPI_TABLE_MADT *)sdp;
+	printf("\tLocal APIC ADDR=0x%08x\n", madt->Address);
 	printf("\tFlags={");
-	if (madtp->flags & ACPI_APIC_FLAG_PCAT_COMPAT)
+	if (madt->Flags & ACPI_MADT_PCAT_COMPAT)
 		printf("PC-AT");
 	printf("}\n");
-	madt_apicp = (struct MADT_APIC *)madtp->body;
-	while (((uintptr_t)madt_apicp) - ((uintptr_t)sdp) < sdp->len) {
-		printf("\n");
-		acpi_print_apic(madt_apicp);
-		madt_apicp = (struct MADT_APIC *) ((char *)madt_apicp +
-		    madt_apicp->len);
-	}
+	acpi_walk_subtables(sdp, (madt + 1), acpi_print_madt);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_hpet(struct ACPIsdt *sdp)
+acpi_handle_hpet(ACPI_TABLE_HEADER *sdp)
 {
-	struct HPETbody *hpetp;
+	ACPI_TABLE_HPET *hpet;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	hpetp = (struct HPETbody *) sdp->body;
-	printf("\tHPET Number=%d\n", hpetp->hpet_number);
+	hpet = (ACPI_TABLE_HPET *)sdp;
+	printf("\tHPET Number=%d\n", hpet->Sequence);
 	printf("\tADDR=");
-	acpi_print_gas(&hpetp->genaddr);
-	printf("\tHW Rev=0x%x\n", hpetp->block_hwrev);
-	printf("\tComparitors=%d\n", hpetp->block_comparitors);
-	printf("\tCounter Size=%d\n", hpetp->block_counter_size);
+	acpi_print_gas(&hpet->Address);
+	printf("\tHW Rev=0x%x\n", hpet->Id & ACPI_HPET_ID_HARDWARE_REV_ID);
+	printf("\tComparators=%d\n", (hpet->Id & ACPI_HPET_ID_COMPARATORS) >>
+	    8);
+	printf("\tCounter Size=%d\n", hpet->Id & ACPI_HPET_ID_COUNT_SIZE_CAP ?
+	    1 : 0);
 	printf("\tLegacy IRQ routing capable={");
-	if (hpetp->block_legacy_capable)
+	if (hpet->Id & ACPI_HPET_ID_LEGACY_CAPABLE)
 		printf("TRUE}\n");
 	else
 		printf("FALSE}\n");
-	printf("\tPCI Vendor ID=0x%04x\n", hpetp->block_pcivendor);
-	printf("\tMinimal Tick=%d\n", hpetp->clock_tick);
+	printf("\tPCI Vendor ID=0x%04x\n", hpet->Id >> 16);
+	printf("\tMinimal Tick=%d\n", hpet->MinimumTick);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_ecdt(struct ACPIsdt *sdp)
+acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp)
 {
-	struct ECDTbody *ecdt;
+	ACPI_TABLE_ECDT *ecdt;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	ecdt = (struct ECDTbody *) sdp->body;
+	ecdt = (ACPI_TABLE_ECDT *)sdp;
 	printf("\tEC_CONTROL=");
-	acpi_print_gas(&ecdt->ec_control);
+	acpi_print_gas(&ecdt->Control);
 	printf("\n\tEC_DATA=");
-	acpi_print_gas(&ecdt->ec_data);
-	printf("\n\tUID=%#x, ", ecdt->uid);
-	printf("GPE_BIT=%#x\n", ecdt->gpe_bit);
-	printf("\tEC_ID=%s\n", ecdt->ec_id);
+	acpi_print_gas(&ecdt->Data);
+	printf("\n\tUID=%#x, ", ecdt->Uid);
+	printf("GPE_BIT=%#x\n", ecdt->Gpe);
+	printf("\tEC_ID=%s\n", ecdt->Id);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_mcfg(struct ACPIsdt *sdp)
+acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp)
 {
-	struct MCFGbody *mcfg;
-	u_int i, e;
+	ACPI_TABLE_MCFG *mcfg;
+	ACPI_MCFG_ALLOCATION *alloc;
+	u_int i, entries;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	mcfg = (struct MCFGbody *) sdp->body;
-
-	e = (sdp->len - ((caddr_t)&mcfg->s[0] - (caddr_t)sdp)) /
-	    sizeof(*mcfg->s);
-	for (i = 0; i < e; i++, mcfg++) {
+	mcfg = (ACPI_TABLE_MCFG *)sdp;
+	entries = (sdp->Length - sizeof(ACPI_TABLE_MCFG)) /
+	    sizeof(ACPI_MCFG_ALLOCATION);
+	alloc = (ACPI_MCFG_ALLOCATION *)(mcfg + 1);
+	for (i = 0; i < entries; i++, alloc++) {
 		printf("\n");
-		printf("\tBase Address=0x%016jx\n", mcfg->s[i].baseaddr);
-		printf("\tSegment Group=0x%04x\n", mcfg->s[i].seg_grp);
-		printf("\tStart Bus=%d\n", mcfg->s[i].start);
-		printf("\tEnd Bus=%d\n", mcfg->s[i].end);
+		printf("\tBase Address=0x%016jx\n", alloc->Address);
+		printf("\tSegment Group=0x%04x\n", alloc->PciSegment);
+		printf("\tStart Bus=%d\n", alloc->StartBusNumber);
+		printf("\tEnd Bus=%d\n", alloc->EndBusNumber);
 	}
 	printf(END_COMMENT);
 }
@@ -423,108 +493,109 @@ acpi_print_srat_cpu(uint32_t apic_id, ui
 }
 
 static void
-acpi_print_srat_memory(struct SRAT_memory *mp)
+acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp)
 {
 
 	printf("\tFlags={");
-	if (mp->flags & ACPI_SRAT_MEM_ENABLED)
+	if (mp->Flags & ACPI_SRAT_MEM_ENABLED)
 		printf("ENABLED");
 	else
 		printf("DISABLED");
-	if (mp->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
+	if (mp->Flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
 		printf(",HOT_PLUGGABLE");
-	if (mp->flags & ACPI_SRAT_MEM_NON_VOLATILE)
+	if (mp->Flags & ACPI_SRAT_MEM_NON_VOLATILE)
 		printf(",NON_VOLATILE");
 	printf("}\n");
-	printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->base_address);
-	printf("\tLength=0x%016jx\n", (uintmax_t)mp->length);
-	printf("\tProximity Domain=%d\n", mp->proximity_domain);
+	printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->BaseAddress);
+	printf("\tLength=0x%016jx\n", (uintmax_t)mp->Length);
+	printf("\tProximity Domain=%d\n", mp->ProximityDomain);
 }
 
 const char *srat_types[] = { "CPU", "Memory", "X2APIC" };
 
 static void
-acpi_print_srat(struct SRATentry *srat)
+acpi_print_srat(ACPI_SUBTABLE_HEADER *srat)
 {
+	ACPI_SRAT_CPU_AFFINITY *cpu;
+	ACPI_SRAT_X2APIC_CPU_AFFINITY *x2apic;
 
-	if (srat->type < sizeof(srat_types) / sizeof(srat_types[0]))
-		printf("\tType=%s\n", srat_types[srat->type]);
+	if (srat->Type < sizeof(srat_types) / sizeof(srat_types[0]))
+		printf("\tType=%s\n", srat_types[srat->Type]);
 	else
-		printf("\tType=%d (unknown)\n", srat->type);
-	switch (srat->type) {
+		printf("\tType=%d (unknown)\n", srat->Type);
+	switch (srat->Type) {
 	case ACPI_SRAT_TYPE_CPU_AFFINITY:
-		acpi_print_srat_cpu(srat->body.cpu.apic_id,
-		    srat->body.cpu.proximity_domain_hi[2] << 24 |
-		    srat->body.cpu.proximity_domain_hi[1] << 16 |
-		    srat->body.cpu.proximity_domain_hi[0] << 0 |
-		    srat->body.cpu.proximity_domain_lo, srat->body.cpu.flags);
+		cpu = (ACPI_SRAT_CPU_AFFINITY *)srat;
+		acpi_print_srat_cpu(cpu->ApicId,
+		    cpu->ProximityDomainHi[2] << 24 |
+		    cpu->ProximityDomainHi[1] << 16 |
+		    cpu->ProximityDomainHi[0] << 0 |
+		    cpu->ProximityDomainLo, cpu->Flags);
 		break;
 	case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
-		acpi_print_srat_memory(&srat->body.mem);
+		acpi_print_srat_memory((ACPI_SRAT_MEM_AFFINITY *)srat);
 		break;
 	case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
-		acpi_print_srat_cpu(srat->body.x2apic.apic_id,
-		    srat->body.x2apic.proximity_domain,
-		    srat->body.x2apic.flags);
+		x2apic = (ACPI_SRAT_X2APIC_CPU_AFFINITY *)srat;
+		acpi_print_srat_cpu(x2apic->ApicId, x2apic->ProximityDomain,
+		    x2apic->Flags);
 		break;
 	}
 }
 
 static void
-acpi_handle_srat(struct ACPIsdt *sdp)
+acpi_handle_srat(ACPI_TABLE_HEADER *sdp)
 {
-	struct SRATbody *sratp;
-	struct SRATentry *entry;
+	ACPI_TABLE_SRAT *srat;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	sratp = (struct SRATbody *)sdp->body;
-	printf("\tTable Revision=%d\n", sratp->table_revision);
-	entry = sratp->body;
-	while (((uintptr_t)entry) - ((uintptr_t)sdp) < sdp->len) {
-		printf("\n");
-		acpi_print_srat(entry);
-		entry = (struct SRATentry *)((char *)entry + entry->len);
-	}
+	srat = (ACPI_TABLE_SRAT *)sdp;
+	printf("\tTable Revision=%d\n", srat->TableRevision);
+	acpi_walk_subtables(sdp, (srat + 1), acpi_print_srat);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_print_sdt(struct ACPIsdt *sdp)
+acpi_print_sdt(ACPI_TABLE_HEADER *sdp)
 {
 	printf("  ");
-	acpi_print_string(sdp->signature, 4);
+	acpi_print_string(sdp->Signature, ACPI_NAME_SIZE);
 	printf(": Length=%d, Revision=%d, Checksum=%d,\n",
-	       sdp->len, sdp->rev, sdp->check);
+	       sdp->Length, sdp->Revision, sdp->Checksum);
 	printf("\tOEMID=");
-	acpi_print_string(sdp->oemid, 6);
+	acpi_print_string(sdp->OemId, ACPI_OEM_ID_SIZE);
 	printf(", OEM Table ID=");
-	acpi_print_string(sdp->oemtblid, 8);
-	printf(", OEM Revision=0x%x,\n", sdp->oemrev);
+	acpi_print_string(sdp->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
+	printf(", OEM Revision=0x%x,\n", sdp->OemRevision);
 	printf("\tCreator ID=");
-	acpi_print_string(sdp->creator, 4);
-	printf(", Creator Revision=0x%x\n", sdp->crerev);
+	acpi_print_string(sdp->AslCompilerId, ACPI_NAME_SIZE);
+	printf(", Creator Revision=0x%x\n", sdp->AslCompilerRevision);
 }
 
 static void
-acpi_print_rsdt(struct ACPIsdt *rsdp)
+acpi_print_rsdt(ACPI_TABLE_HEADER *rsdp)
 {
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
 	int	i, entries;
 	u_long	addr;
 
+	rsdt = (ACPI_TABLE_RSDT *)rsdp;
+	xsdt = (ACPI_TABLE_XSDT *)rsdp;
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(rsdp);
-	entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size;
+	entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size;
 	printf("\tEntries={ ");
 	for (i = 0; i < entries; i++) {
 		if (i > 0)
 			printf(", ");
 		switch (addr_size) {
 		case 4:
-			addr = le32dec((char*)rsdp->body + i * addr_size);
+			addr = le32toh(rsdt->TableOffsetEntry[i]);
 			break;
 		case 8:
-			addr = le64dec((char*)rsdp->body + i * addr_size);
+			addr = le64toh(xsdt->TableOffsetEntry[i]);
 			break;
 		default:
 			addr = 0;
@@ -542,138 +613,147 @@ static const char *acpi_pm_profiles[] = 
 };
 
 static void
-acpi_print_fadt(struct ACPIsdt *sdp)
+acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
 {
-	struct FADTbody *fadt;
+	ACPI_TABLE_FADT *fadt;
 	const char *pm;
 	char	    sep;
 
-	fadt = (struct FADTbody *)sdp->body;
+	fadt = (ACPI_TABLE_FADT *)sdp;
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->facs_ptr,
-	       fadt->dsdt_ptr);
-	printf("\tINT_MODEL=%s\n", fadt->int_model ? "APIC" : "PIC");
-	if (fadt->pm_profile >= sizeof(acpi_pm_profiles) / sizeof(char *))
+	printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->Facs,
+	       fadt->Dsdt);
+	printf("\tINT_MODEL=%s\n", fadt->Model ? "APIC" : "PIC");
+	if (fadt->PreferredProfile >= sizeof(acpi_pm_profiles) / sizeof(char *))
 		pm = "Reserved";
 	else
-		pm = acpi_pm_profiles[fadt->pm_profile];
-	printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->pm_profile);
-	printf("\tSCI_INT=%d\n", fadt->sci_int);
-	printf("\tSMI_CMD=0x%x, ", fadt->smi_cmd);
-	printf("ACPI_ENABLE=0x%x, ", fadt->acpi_enable);
-	printf("ACPI_DISABLE=0x%x, ", fadt->acpi_disable);
-	printf("S4BIOS_REQ=0x%x\n", fadt->s4biosreq);
-	printf("\tPSTATE_CNT=0x%x\n", fadt->pstate_cnt);
+		pm = acpi_pm_profiles[fadt->PreferredProfile];
+	printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->PreferredProfile);
+	printf("\tSCI_INT=%d\n", fadt->SciInterrupt);
+	printf("\tSMI_CMD=0x%x, ", fadt->SmiCommand);
+	printf("ACPI_ENABLE=0x%x, ", fadt->AcpiEnable);
+	printf("ACPI_DISABLE=0x%x, ", fadt->AcpiDisable);
+	printf("S4BIOS_REQ=0x%x\n", fadt->S4BiosRequest);
+	printf("\tPSTATE_CNT=0x%x\n", fadt->PstateControl);
 	printf("\tPM1a_EVT_BLK=0x%x-0x%x\n",
-	       fadt->pm1a_evt_blk,
-	       fadt->pm1a_evt_blk + fadt->pm1_evt_len - 1);
-	if (fadt->pm1b_evt_blk != 0)
+	       fadt->Pm1aEventBlock,
+	       fadt->Pm1aEventBlock + fadt->Pm1EventLength - 1);
+	if (fadt->Pm1bEventBlock != 0)
 		printf("\tPM1b_EVT_BLK=0x%x-0x%x\n",
-		       fadt->pm1b_evt_blk,
-		       fadt->pm1b_evt_blk + fadt->pm1_evt_len - 1);
+		       fadt->Pm1bEventBlock,
+		       fadt->Pm1bEventBlock + fadt->Pm1EventLength - 1);
 	printf("\tPM1a_CNT_BLK=0x%x-0x%x\n",
-	       fadt->pm1a_cnt_blk,
-	       fadt->pm1a_cnt_blk + fadt->pm1_cnt_len - 1);
-	if (fadt->pm1b_cnt_blk != 0)
+	       fadt->Pm1aControlBlock,
+	       fadt->Pm1aControlBlock + fadt->Pm1ControlLength - 1);
+	if (fadt->Pm1bControlBlock != 0)
 		printf("\tPM1b_CNT_BLK=0x%x-0x%x\n",
-		       fadt->pm1b_cnt_blk,
-		       fadt->pm1b_cnt_blk + fadt->pm1_cnt_len - 1);
-	if (fadt->pm2_cnt_blk != 0)
+		       fadt->Pm1bControlBlock,
+		       fadt->Pm1bControlBlock + fadt->Pm1ControlLength - 1);
+	if (fadt->Pm2ControlBlock != 0)
 		printf("\tPM2_CNT_BLK=0x%x-0x%x\n",
-		       fadt->pm2_cnt_blk,
-		       fadt->pm2_cnt_blk + fadt->pm2_cnt_len - 1);
+		       fadt->Pm2ControlBlock,
+		       fadt->Pm2ControlBlock + fadt->Pm2ControlLength - 1);
 	printf("\tPM_TMR_BLK=0x%x-0x%x\n",
-	       fadt->pm_tmr_blk,
-	       fadt->pm_tmr_blk + fadt->pm_tmr_len - 1);
-	if (fadt->gpe0_blk != 0)
+	       fadt->PmTimerBlock,
+	       fadt->PmTimerBlock + fadt->PmTimerLength - 1);
+	if (fadt->Gpe0Block != 0)
 		printf("\tGPE0_BLK=0x%x-0x%x\n",
-		       fadt->gpe0_blk,
-		       fadt->gpe0_blk + fadt->gpe0_len - 1);
-	if (fadt->gpe1_blk != 0)
+		       fadt->Gpe0Block,
+		       fadt->Gpe0Block + fadt->Gpe0BlockLength - 1);
+	if (fadt->Gpe1Block != 0)
 		printf("\tGPE1_BLK=0x%x-0x%x, GPE1_BASE=%d\n",
-		       fadt->gpe1_blk,
-		       fadt->gpe1_blk + fadt->gpe1_len - 1,
-		       fadt->gpe1_base);
-	if (fadt->cst_cnt != 0)
-		printf("\tCST_CNT=0x%x\n", fadt->cst_cnt);
+		       fadt->Gpe1Block,
+		       fadt->Gpe1Block + fadt->Gpe1BlockLength - 1,
+		       fadt->Gpe1Base);
+	if (fadt->CstControl != 0)
+		printf("\tCST_CNT=0x%x\n", fadt->CstControl);
 	printf("\tP_LVL2_LAT=%d us, P_LVL3_LAT=%d us\n",
-	       fadt->p_lvl2_lat, fadt->p_lvl3_lat);
+	       fadt->C2Latency, fadt->C3Latency);
 	printf("\tFLUSH_SIZE=%d, FLUSH_STRIDE=%d\n",
-	       fadt->flush_size, fadt->flush_stride);
+	       fadt->FlushSize, fadt->FlushStride);
 	printf("\tDUTY_OFFSET=%d, DUTY_WIDTH=%d\n",
-	       fadt->duty_off, fadt->duty_width);
+	       fadt->DutyOffset, fadt->DutyWidth);
 	printf("\tDAY_ALRM=%d, MON_ALRM=%d, CENTURY=%d\n",
-	       fadt->day_alrm, fadt->mon_alrm, fadt->century);
+	       fadt->DayAlarm, fadt->MonthAlarm, fadt->Century);
 
 #define PRINTFLAG(var, flag) do {			\
-	if ((var) & FADT_FLAG_## flag) {		\
+	if ((var) & ACPI_FADT_## flag) {		\
 		printf("%c%s", sep, #flag); sep = ',';	\
 	}						\
 } while (0)
 
 	printf("\tIAPC_BOOT_ARCH=");
 	sep = '{';
-	PRINTFLAG(fadt->iapc_boot_arch, LEGACY_DEV);
-	PRINTFLAG(fadt->iapc_boot_arch, 8042);
-	if (fadt->iapc_boot_arch != 0)
+	PRINTFLAG(fadt->BootFlags, LEGACY_DEVICES);
+	PRINTFLAG(fadt->BootFlags, 8042);
+	PRINTFLAG(fadt->BootFlags, NO_VGA);
+	PRINTFLAG(fadt->BootFlags, NO_MSI);
+	PRINTFLAG(fadt->BootFlags, NO_ASPM);
+	if (fadt->BootFlags != 0)
 		printf("}");
 	printf("\n");
 
 	printf("\tFlags=");
 	sep = '{';
-	PRINTFLAG(fadt->flags, WBINVD);
-	PRINTFLAG(fadt->flags, WBINVD_FLUSH);
-	PRINTFLAG(fadt->flags, PROC_C1);
-	PRINTFLAG(fadt->flags, P_LVL2_UP);
-	PRINTFLAG(fadt->flags, PWR_BUTTON);
-	PRINTFLAG(fadt->flags, SLP_BUTTON);
-	PRINTFLAG(fadt->flags, FIX_RTC);
-	PRINTFLAG(fadt->flags, RTC_S4);
-	PRINTFLAG(fadt->flags, TMR_VAL_EXT);
-	PRINTFLAG(fadt->flags, DCK_CAP);
-	PRINTFLAG(fadt->flags, RESET_REG);
-	PRINTFLAG(fadt->flags, SEALED_CASE);
-	PRINTFLAG(fadt->flags, HEADLESS);
-	PRINTFLAG(fadt->flags, CPU_SW_SLP);
-	if (fadt->flags != 0)
+	PRINTFLAG(fadt->Flags, WBINVD);
+	PRINTFLAG(fadt->Flags, WBINVD_FLUSH);
+	PRINTFLAG(fadt->Flags, C1_SUPPORTED);
+	PRINTFLAG(fadt->Flags, C2_MP_SUPPORTED);
+	PRINTFLAG(fadt->Flags, POWER_BUTTON);
+	PRINTFLAG(fadt->Flags, SLEEP_BUTTON);
+	PRINTFLAG(fadt->Flags, FIXED_RTC);
+	PRINTFLAG(fadt->Flags, S4_RTC_WAKE);
+	PRINTFLAG(fadt->Flags, 32BIT_TIMER);
+	PRINTFLAG(fadt->Flags, DOCKING_SUPPORTED);
+	PRINTFLAG(fadt->Flags, RESET_REGISTER);
+	PRINTFLAG(fadt->Flags, SEALED_CASE);
+	PRINTFLAG(fadt->Flags, HEADLESS);
+	PRINTFLAG(fadt->Flags, SLEEP_TYPE);
+	PRINTFLAG(fadt->Flags, PCI_EXPRESS_WAKE);
+	PRINTFLAG(fadt->Flags, PLATFORM_CLOCK);
+	PRINTFLAG(fadt->Flags, S4_RTC_VALID);
+	PRINTFLAG(fadt->Flags, REMOTE_POWER_ON);
+	PRINTFLAG(fadt->Flags, APIC_CLUSTER);
+	PRINTFLAG(fadt->Flags, APIC_PHYSICAL);
+	if (fadt->Flags != 0)
 		printf("}\n");
 
 #undef PRINTFLAG
 
-	if (fadt->flags & FADT_FLAG_RESET_REG) {
+	if (fadt->Flags & ACPI_FADT_RESET_REGISTER) {
 		printf("\tRESET_REG=");
-		acpi_print_gas(&fadt->reset_reg);
-		printf(", RESET_VALUE=%#x\n", fadt->reset_value);
+		acpi_print_gas(&fadt->ResetRegister);
+		printf(", RESET_VALUE=%#x\n", fadt->ResetValue);
 	}
 	if (acpi_get_fadt_revision(fadt) > 1) {
-		printf("\tX_FACS=0x%08lx, ", (u_long)fadt->x_facs_ptr);
-		printf("X_DSDT=0x%08lx\n", (u_long)fadt->x_dsdt_ptr);
+		printf("\tX_FACS=0x%08lx, ", (u_long)fadt->XFacs);
+		printf("X_DSDT=0x%08lx\n", (u_long)fadt->XDsdt);
 		printf("\tX_PM1a_EVT_BLK=");
-		acpi_print_gas(&fadt->x_pm1a_evt_blk);
-		if (fadt->x_pm1b_evt_blk.address != 0) {
+		acpi_print_gas(&fadt->XPm1aEventBlock);
+		if (fadt->XPm1bEventBlock.Address != 0) {
 			printf("\n\tX_PM1b_EVT_BLK=");
-			acpi_print_gas(&fadt->x_pm1b_evt_blk);
+			acpi_print_gas(&fadt->XPm1bEventBlock);
 		}
 		printf("\n\tX_PM1a_CNT_BLK=");
-		acpi_print_gas(&fadt->x_pm1a_cnt_blk);
-		if (fadt->x_pm1b_cnt_blk.address != 0) {
+		acpi_print_gas(&fadt->XPm1aControlBlock);
+		if (fadt->XPm1bControlBlock.Address != 0) {
 			printf("\n\tX_PM1b_CNT_BLK=");
-			acpi_print_gas(&fadt->x_pm1b_cnt_blk);
+			acpi_print_gas(&fadt->XPm1bControlBlock);
 		}
-		if (fadt->x_pm1b_cnt_blk.address != 0) {
+		if (fadt->XPm2ControlBlock.Address != 0) {
 			printf("\n\tX_PM2_CNT_BLK=");
-			acpi_print_gas(&fadt->x_pm2_cnt_blk);
+			acpi_print_gas(&fadt->XPm2ControlBlock);
 		}
 		printf("\n\tX_PM_TMR_BLK=");
-		acpi_print_gas(&fadt->x_pm_tmr_blk);
-		if (fadt->x_gpe0_blk.address != 0) {
+		acpi_print_gas(&fadt->XPmTimerBlock);
+		if (fadt->XGpe0Block.Address != 0) {
 			printf("\n\tX_GPE0_BLK=");
-			acpi_print_gas(&fadt->x_gpe0_blk);
+			acpi_print_gas(&fadt->XGpe0Block);
 		}
-		if (fadt->x_gpe1_blk.address != 0) {
+		if (fadt->XGpe1Block.Address != 0) {
 			printf("\n\tX_GPE1_BLK=");
-			acpi_print_gas(&fadt->x_gpe1_blk);
+			acpi_print_gas(&fadt->XGpe1Block);
 		}
 		printf("\n");
 	}
@@ -682,38 +762,38 @@ acpi_print_fadt(struct ACPIsdt *sdp)
 }
 
 static void
-acpi_print_facs(struct FACSbody *facs)
+acpi_print_facs(ACPI_TABLE_FACS *facs)
 {
 	printf(BEGIN_COMMENT);
-	printf("  FACS:\tLength=%u, ", facs->len);
-	printf("HwSig=0x%08x, ", facs->hw_sig);
-	printf("Firm_Wake_Vec=0x%08x\n", facs->firm_wake_vec);
+	printf("  FACS:\tLength=%u, ", facs->Length);
+	printf("HwSig=0x%08x, ", facs->HardwareSignature);
+	printf("Firm_Wake_Vec=0x%08x\n", facs->FirmwareWakingVector);
 
 	printf("\tGlobal_Lock=");
-	if (facs->global_lock != 0) {
-		if (facs->global_lock & FACS_FLAG_LOCK_PENDING)
+	if (facs->GlobalLock != 0) {
+		if (facs->GlobalLock & ACPI_GLOCK_PENDING)
 			printf("PENDING,");
-		if (facs->global_lock & FACS_FLAG_LOCK_OWNED)
+		if (facs->GlobalLock & ACPI_GLOCK_OWNED)
 			printf("OWNED");
 	}
 	printf("\n");
 
 	printf("\tFlags=");
-	if (facs->flags & FACS_FLAG_S4BIOS_F)
+	if (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT)
 		printf("S4BIOS");
 	printf("\n");
 
-	if (facs->x_firm_wake_vec != 0) {
+	if (facs->XFirmwareWakingVector != 0) {
 		printf("\tX_Firm_Wake_Vec=%08lx\n",
-		       (u_long)facs->x_firm_wake_vec);
+		       (u_long)facs->XFirmwareWakingVector);
 	}
-	printf("\tVersion=%u\n", facs->version);
+	printf("\tVersion=%u\n", facs->Version);
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 14:52:33 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7DE7E106568B;
	Thu, 29 Oct 2009 14:52:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6AE418FC1B;
	Thu, 29 Oct 2009 14:52:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TEqXQH099861;
	Thu, 29 Oct 2009 14:52:33 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TEqX7L099858;
	Thu, 29 Oct 2009 14:52:33 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291452.n9TEqX7L099858@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 14:52:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198592 - in stable/7/usr.sbin/acpi: . acpidump
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 14:52:33 -0000

Author: jhb
Date: Thu Oct 29 14:52:32 2009
New Revision: 198592
URL: http://svn.freebsd.org/changeset/base/198592

Log:
  MFC 196555:
  - Use the headers from ACPI-CA to define various constants and structures
    for table layouts, etc. rather than homerolling our own structures and
    constants in acpidump.h.
  - Verify the extended checksum on the RSDP.
  - One side effect in this branch is that we lose support for parsing SRAT
    X2APIC entries since the ACPI-CA headers do not include those.  I have
    yet to see one of these in the wild, however.

Modified:
  stable/7/usr.sbin/acpi/   (props changed)
  stable/7/usr.sbin/acpi/acpidump/acpi.c
  stable/7/usr.sbin/acpi/acpidump/acpi_user.c
  stable/7/usr.sbin/acpi/acpidump/acpidump.c
  stable/7/usr.sbin/acpi/acpidump/acpidump.h

Modified: stable/7/usr.sbin/acpi/acpidump/acpi.c
==============================================================================
--- stable/7/usr.sbin/acpi/acpidump/acpi.c	Thu Oct 29 14:40:21 2009	(r198591)
+++ stable/7/usr.sbin/acpi/acpidump/acpi.c	Thu Oct 29 14:52:32 2009	(r198592)
@@ -45,31 +45,36 @@
 #define END_COMMENT	" */\n"
 
 static void	acpi_print_string(char *s, size_t length);
-static void	acpi_print_gas(struct ACPIgas *gas);
-static int	acpi_get_fadt_revision(struct FADTbody *fadt);
-static void	acpi_handle_fadt(struct ACPIsdt *fadt);
+static void	acpi_print_gas(ACPI_GENERIC_ADDRESS *gas);
+static int	acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt);
+static void	acpi_handle_fadt(ACPI_TABLE_HEADER *fadt);
 static void	acpi_print_cpu(u_char cpu_id);
-static void	acpi_print_local_apic(u_char cpu_id, u_char apic_id,
-				      u_int32_t flags);
-static void	acpi_print_io_apic(u_char apic_id, u_int32_t int_base,
-				   u_int64_t apic_addr);
-static void	acpi_print_mps_flags(u_int16_t flags);
-static void	acpi_print_intr(u_int32_t intr, u_int16_t mps_flags);
-static void	acpi_print_apic(struct MADT_APIC *mp);
-static void	acpi_handle_apic(struct ACPIsdt *sdp);
-static void	acpi_handle_hpet(struct ACPIsdt *sdp);
+static void	acpi_print_cpu_uid(uint32_t uid, char *uid_string);
+static void	acpi_print_local_apic(uint32_t apic_id, uint32_t flags);
+static void	acpi_print_io_apic(uint32_t apic_id, uint32_t int_base,
+		    uint64_t apic_addr);
+static void	acpi_print_mps_flags(uint16_t flags);
+static void	acpi_print_intr(uint32_t intr, uint16_t mps_flags);
+static void	acpi_print_local_nmi(u_int lint, uint16_t mps_flags);
+static void	acpi_print_madt(ACPI_SUBTABLE_HEADER *mp);
+static void	acpi_handle_madt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_hpet(ACPI_TABLE_HEADER *sdp);
+static void	acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp);
 static void	acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain,
 		    uint32_t flags);
-static void	acpi_print_srat_memory(struct SRAT_memory *mp);
-static void	acpi_print_srat(struct SRATentry *srat);
-static void	acpi_handle_srat(struct ACPIsdt *sdp);
-static void	acpi_print_sdt(struct ACPIsdt *sdp);
-static void	acpi_print_fadt(struct ACPIsdt *sdp);
-static void	acpi_print_facs(struct FACSbody *facs);
-static void	acpi_print_dsdt(struct ACPIsdt *dsdp);
-static struct ACPIsdt *acpi_map_sdt(vm_offset_t pa);
-static void	acpi_print_rsd_ptr(struct ACPIrsdp *rp);
-static void	acpi_handle_rsdt(struct ACPIsdt *rsdp);
+static void	acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp);
+static void	acpi_print_srat(ACPI_SUBTABLE_HEADER *srat);
+static void	acpi_handle_srat(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_sdt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_fadt(ACPI_TABLE_HEADER *sdp);
+static void	acpi_print_facs(ACPI_TABLE_FACS *facs);
+static void	acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp);
+static ACPI_TABLE_HEADER *acpi_map_sdt(vm_offset_t pa);
+static void	acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp);
+static void	acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp);
+static void	acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first,
+		    void (*action)(ACPI_SUBTABLE_HEADER *));
 
 /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */
 static int addr_size;
@@ -90,41 +95,44 @@ acpi_print_string(char *s, size_t length
 }
 
 static void
-acpi_print_gas(struct ACPIgas *gas)
+acpi_print_gas(ACPI_GENERIC_ADDRESS *gas)
 {
-	switch(gas->address_space_id) {
+	switch(gas->SpaceId) {
 	case ACPI_GAS_MEMORY:
-		printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_IO:
-		printf("0x%02lx:%u[%u] (IO)", (u_long)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%02lx:%u[%u] (IO)", (u_long)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_PCI:
-		printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->address >> 32),
-		       (uint16_t)((gas->address >> 16) & 0xffff),
-		       (uint16_t)gas->address);
+		printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->Address >> 32),
+		       (uint16_t)((gas->Address >> 16) & 0xffff),
+		       (uint16_t)gas->Address);
 		break;
 	/* XXX How to handle these below? */
 	case ACPI_GAS_EMBEDDED:
-		printf("0x%x:%u[%u] (EC)", (uint16_t)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%x:%u[%u] (EC)", (uint16_t)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
 	case ACPI_GAS_SMBUS:
-		printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->address,
-		       gas->bit_offset, gas->bit_width);
+		printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->Address,
+		       gas->BitOffset, gas->BitWidth);
 		break;
+	case ACPI_GAS_CMOS:
+	case ACPI_GAS_PCIBAR:
+	case ACPI_GAS_DATATABLE:
 	case ACPI_GAS_FIXED:
 	default:
-		printf("0x%08lx (?)", (u_long)gas->address);
+		printf("0x%08lx (?)", (u_long)gas->Address);
 		break;
 	}
 }
 
 /* The FADT revision indicates whether we use the DSDT or X_DSDT addresses. */
 static int
-acpi_get_fadt_revision(struct FADTbody *fadt)
+acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt)
 {
 	int fadt_revision;
 
@@ -139,8 +147,8 @@ acpi_get_fadt_revision(struct FADTbody *
 		 * 32 and 64 bit versions don't match, prefer the 32 bit
 		 * version for all subsequent tables.
 		 */
-		if (fadt->facs_ptr != 0 &&
-		    (fadt->x_facs_ptr & 0xffffffff) != fadt->facs_ptr)
+		if (fadt->Facs != 0 &&
+		    (fadt->XFacs & 0xffffffff) != fadt->Facs)
 			fadt_revision = 1;
 	} else
 		fadt_revision = 1;
@@ -148,35 +156,52 @@ acpi_get_fadt_revision(struct FADTbody *
 }
 
 static void
-acpi_handle_fadt(struct ACPIsdt *sdp)
+acpi_handle_fadt(ACPI_TABLE_HEADER *sdp)
 {
-	struct ACPIsdt	*dsdp;
-	struct FACSbody	*facs;
-	struct FADTbody *fadt;
+	ACPI_TABLE_HEADER *dsdp;
+	ACPI_TABLE_FACS	*facs;
+	ACPI_TABLE_FADT *fadt;
 	int		fadt_revision;
 
-	fadt = (struct FADTbody *)sdp->body;
+	fadt = (ACPI_TABLE_FADT *)sdp;
 	acpi_print_fadt(sdp);
 
 	fadt_revision = acpi_get_fadt_revision(fadt);
 	if (fadt_revision == 1)
-		facs = (struct FACSbody *)acpi_map_sdt(fadt->facs_ptr);
+		facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs);
 	else
-		facs = (struct FACSbody *)acpi_map_sdt(fadt->x_facs_ptr);
-	if (memcmp(facs->signature, "FACS", 4) != 0 || facs->len < 64)
+		facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs);
+	if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)
 		errx(1, "FACS is corrupt");
 	acpi_print_facs(facs);
 
 	if (fadt_revision == 1)
-		dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr);
+		dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt);
 	else
-		dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr);
-	if (acpi_checksum(dsdp, dsdp->len))
+		dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt);
+	if (acpi_checksum(dsdp, dsdp->Length))
 		errx(1, "DSDT is corrupt");
 	acpi_print_dsdt(dsdp);
 }
 
 static void
+acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first,
+    void (*action)(ACPI_SUBTABLE_HEADER *))
+{
+	ACPI_SUBTABLE_HEADER *subtable;
+	char *end;
+
+	subtable = first;
+	end = (char *)table + table->Length;
+	while ((char *)subtable < end) {
+		printf("\n");
+		action(subtable);
+		subtable = (ACPI_SUBTABLE_HEADER *)((char *)subtable +
+		    subtable->Length);
+	}
+}
+
+static void
 acpi_print_cpu(u_char cpu_id)
 {
 
@@ -188,219 +213,251 @@ acpi_print_cpu(u_char cpu_id)
 }
 
 static void
-acpi_print_local_apic(u_char cpu_id, u_char apic_id, u_int32_t flags)
+acpi_print_cpu_uid(uint32_t uid, char *uid_string)
+{
+
+	printf("\tUID=%d", uid);
+	if (uid_string != NULL)
+		printf(" (%s)", uid_string);
+	printf("\n");
+}
+
+static void
+acpi_print_local_apic(uint32_t apic_id, uint32_t flags)
 {
-	acpi_print_cpu(cpu_id);
+
 	printf("\tFlags={");
-	if (flags & ACPI_MADT_APIC_LOCAL_FLAG_ENABLED)
+	if (flags & ACPI_MADT_ENABLED)
 		printf("ENABLED");
 	else
 		printf("DISABLED");
 	printf("}\n");
-	printf("\tAPIC ID=%d\n", (u_int)apic_id);
+	printf("\tAPIC ID=%d\n", apic_id);
 }
 
 static void
-acpi_print_io_apic(u_char apic_id, u_int32_t int_base, u_int64_t apic_addr)
+acpi_print_io_apic(uint32_t apic_id, uint32_t int_base, uint64_t apic_addr)
 {
-	printf("\tAPIC ID=%d\n", (u_int)apic_id);
+
+	printf("\tAPIC ID=%d\n", apic_id);
 	printf("\tINT BASE=%d\n", int_base);
-	printf("\tADDR=0x%016jx\n", apic_addr);
+	printf("\tADDR=0x%016jx\n", (uintmax_t)apic_addr);
 }
 
 static void
-acpi_print_mps_flags(u_int16_t flags)
+acpi_print_mps_flags(uint16_t flags)
 {
 
 	printf("\tFlags={Polarity=");
-	switch (flags & MPS_INT_FLAG_POLARITY_MASK) {
-	case MPS_INT_FLAG_POLARITY_CONFORM:
+	switch (flags & ACPI_MADT_POLARITY_MASK) {
+	case ACPI_MADT_POLARITY_CONFORMS:
 		printf("conforming");
 		break;
-	case MPS_INT_FLAG_POLARITY_HIGH:
+	case ACPI_MADT_POLARITY_ACTIVE_HIGH:
 		printf("active-hi");
 		break;
-	case MPS_INT_FLAG_POLARITY_LOW:
+	case ACPI_MADT_POLARITY_ACTIVE_LOW:
 		printf("active-lo");
 		break;
 	default:
-		printf("0x%x", flags & MPS_INT_FLAG_POLARITY_MASK);
+		printf("0x%x", flags & ACPI_MADT_POLARITY_MASK);
 		break;
 	}
 	printf(", Trigger=");
-	switch (flags & MPS_INT_FLAG_TRIGGER_MASK) {
-	case MPS_INT_FLAG_TRIGGER_CONFORM:
+	switch (flags & ACPI_MADT_TRIGGER_MASK) {
+	case ACPI_MADT_TRIGGER_CONFORMS:
 		printf("conforming");
 		break;
-	case MPS_INT_FLAG_TRIGGER_EDGE:
+	case ACPI_MADT_TRIGGER_EDGE:
 		printf("edge");
 		break;
-	case MPS_INT_FLAG_TRIGGER_LEVEL:
+	case ACPI_MADT_TRIGGER_LEVEL:
 		printf("level");
 		break;
 	default:
-		printf("0x%x", (flags & MPS_INT_FLAG_TRIGGER_MASK) >> 2);
+		printf("0x%x", (flags & ACPI_MADT_TRIGGER_MASK) >> 2);
 	}
 	printf("}\n");
 }
 
 static void
-acpi_print_intr(u_int32_t intr, u_int16_t mps_flags)
+acpi_print_intr(uint32_t intr, uint16_t mps_flags)
+{
+
+	printf("\tINTR=%d\n", intr);
+	acpi_print_mps_flags(mps_flags);
+}
+
+static void
+acpi_print_local_nmi(u_int lint, uint16_t mps_flags)
 {
 
-	printf("\tINTR=%d\n", (u_int)intr);
+	printf("\tLINT Pin=%d\n", lint);
 	acpi_print_mps_flags(mps_flags);
 }
 
 const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI",
-			     "Local NMI", "Local APIC Override", "IO SAPIC",
-			     "Local SAPIC", "Platform Interrupt" };
-const char *platform_int_types[] = { "PMI", "INIT",
+			     "Local APIC NMI", "Local APIC Override",
+			     "IO SAPIC", "Local SAPIC", "Platform Interrupt" };
+const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT",
 				     "Corrected Platform Error" };
 
 static void
-acpi_print_apic(struct MADT_APIC *mp)
+acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
 {
-
-	if (mp->type < sizeof(apic_types) / sizeof(apic_types[0]))
-		printf("\tType=%s\n", apic_types[mp->type]);
-	else
-		printf("\tType=%d (unknown)\n", mp->type);
-	switch (mp->type) {
-	case ACPI_MADT_APIC_TYPE_LOCAL_APIC:
-		acpi_print_local_apic(mp->body.local_apic.cpu_id,
-		    mp->body.local_apic.apic_id, mp->body.local_apic.flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_IO_APIC:
-		acpi_print_io_apic(mp->body.io_apic.apic_id,
-		    mp->body.io_apic.int_base,
-		    mp->body.io_apic.apic_addr);
-		break;
-	case ACPI_MADT_APIC_TYPE_INT_OVERRIDE:
-		printf("\tBUS=%d\n", (u_int)mp->body.int_override.bus);
-		printf("\tIRQ=%d\n", (u_int)mp->body.int_override.source);
-		acpi_print_intr(mp->body.int_override.intr,
-		    mp->body.int_override.mps_flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_NMI:
-		acpi_print_intr(mp->body.nmi.intr, mp->body.nmi.mps_flags);
-		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_NMI:
-		acpi_print_cpu(mp->body.local_nmi.cpu_id);
-		printf("\tLINT Pin=%d\n", mp->body.local_nmi.lintpin);
-		acpi_print_mps_flags(mp->body.local_nmi.mps_flags);
+	ACPI_MADT_LOCAL_APIC *lapic;
+	ACPI_MADT_IO_APIC *ioapic;
+	ACPI_MADT_INTERRUPT_OVERRIDE *over;
+	ACPI_MADT_NMI_SOURCE *nmi;
+	ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi;
+	ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic_over;
+	ACPI_MADT_IO_SAPIC *iosapic;
+	ACPI_MADT_LOCAL_SAPIC *lsapic;
+	ACPI_MADT_INTERRUPT_SOURCE *isrc;
+
+	if (mp->Type < sizeof(apic_types) / sizeof(apic_types[0]))
+		printf("\tType=%s\n", apic_types[mp->Type]);
+	else
+		printf("\tType=%d (unknown)\n", mp->Type);
+	switch (mp->Type) {
+	case ACPI_MADT_TYPE_LOCAL_APIC:
+		lapic = (ACPI_MADT_LOCAL_APIC *)mp;
+		acpi_print_cpu(lapic->ProcessorId);
+		acpi_print_local_apic(lapic->Id, lapic->LapicFlags);
+		break;
+	case ACPI_MADT_TYPE_IO_APIC:
+		ioapic = (ACPI_MADT_IO_APIC *)mp;
+		acpi_print_io_apic(ioapic->Id, ioapic->GlobalIrqBase,
+		    ioapic->Address);
+		break;
+	case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
+		over = (ACPI_MADT_INTERRUPT_OVERRIDE *)mp;
+		printf("\tBUS=%d\n", (u_int)over->Bus);
+		printf("\tIRQ=%d\n", (u_int)over->SourceIrq);
+		acpi_print_intr(over->GlobalIrq, over->IntiFlags);
+		break;
+	case ACPI_MADT_TYPE_NMI_SOURCE:
+		nmi = (ACPI_MADT_NMI_SOURCE *)mp;
+		acpi_print_intr(nmi->GlobalIrq, nmi->IntiFlags);
+		break;
+	case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
+		lapic_nmi = (ACPI_MADT_LOCAL_APIC_NMI *)mp;
+		acpi_print_cpu(lapic_nmi->ProcessorId);
+		acpi_print_local_nmi(lapic_nmi->Lint, lapic_nmi->IntiFlags);
 		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE:
+	case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
+		lapic_over = (ACPI_MADT_LOCAL_APIC_OVERRIDE *)mp;
 		printf("\tLocal APIC ADDR=0x%016jx\n",
-		    mp->body.local_apic_override.apic_addr);
+		    (uintmax_t)lapic_over->Address);
 		break;
-	case ACPI_MADT_APIC_TYPE_IO_SAPIC:
-		acpi_print_io_apic(mp->body.io_sapic.apic_id,
-		    mp->body.io_sapic.int_base,
-		    mp->body.io_sapic.apic_addr);
+	case ACPI_MADT_TYPE_IO_SAPIC:
+		iosapic = (ACPI_MADT_IO_SAPIC *)mp;
+		acpi_print_io_apic(iosapic->Id, iosapic->GlobalIrqBase,
+		    iosapic->Address);
 		break;
-	case ACPI_MADT_APIC_TYPE_LOCAL_SAPIC:
-		acpi_print_local_apic(mp->body.local_sapic.cpu_id,
-		    mp->body.local_sapic.apic_id, mp->body.local_sapic.flags);
-		printf("\tAPIC EID=%d\n", (u_int)mp->body.local_sapic.apic_eid);
+	case ACPI_MADT_TYPE_LOCAL_SAPIC:
+		lsapic = (ACPI_MADT_LOCAL_SAPIC *)mp;
+		acpi_print_cpu(lsapic->ProcessorId);
+		acpi_print_local_apic(lsapic->Id, lsapic->LapicFlags);
+		printf("\tAPIC EID=%d\n", (u_int)lsapic->Eid);
+		if (mp->Length > __offsetof(ACPI_MADT_LOCAL_SAPIC, Uid))
+			acpi_print_cpu_uid(lsapic->Uid, lsapic->UidString);
 		break;
-	case ACPI_MADT_APIC_TYPE_INT_SRC:
-		printf("\tType=%s\n",
-		    platform_int_types[mp->body.int_src.type]);
-		printf("\tCPU ID=%d\n", (u_int)mp->body.int_src.cpu_id);
-		printf("\tCPU EID=%d\n", (u_int)mp->body.int_src.cpu_id);
-		printf("\tSAPIC Vector=%d\n",
-		    (u_int)mp->body.int_src.sapic_vector);
-		acpi_print_intr(mp->body.int_src.intr,
-		    mp->body.int_src.mps_flags);
+	case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
+		isrc = (ACPI_MADT_INTERRUPT_SOURCE *)mp;
+		if (isrc->Type < sizeof(platform_int_types) /
+		    sizeof(platform_int_types[0]))
+			printf("\tType=%s\n", platform_int_types[isrc->Type]);
+		else
+			printf("\tType=%d (unknown)\n", isrc->Type);
+		printf("\tAPIC ID=%d\n", (u_int)isrc->Id);
+		printf("\tAPIC EID=%d\n", (u_int)isrc->Eid);
+		printf("\tSAPIC Vector=%d\n", (u_int)isrc->IoSapicVector);
+		acpi_print_intr(isrc->GlobalIrq, isrc->IntiFlags);
 		break;
 	}
 }
 
 static void
-acpi_handle_apic(struct ACPIsdt *sdp)
+acpi_handle_madt(ACPI_TABLE_HEADER *sdp)
 {
-	struct MADTbody *madtp;
-	struct MADT_APIC *madt_apicp;
+	ACPI_TABLE_MADT *madt;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	madtp = (struct MADTbody *) sdp->body;
-	printf("\tLocal APIC ADDR=0x%08x\n", madtp->lapic_addr);
+	madt = (ACPI_TABLE_MADT *)sdp;
+	printf("\tLocal APIC ADDR=0x%08x\n", madt->Address);
 	printf("\tFlags={");
-	if (madtp->flags & ACPI_APIC_FLAG_PCAT_COMPAT)
+	if (madt->Flags & ACPI_MADT_PCAT_COMPAT)
 		printf("PC-AT");
 	printf("}\n");
-	madt_apicp = (struct MADT_APIC *)madtp->body;
-	while (((uintptr_t)madt_apicp) - ((uintptr_t)sdp) < sdp->len) {
-		printf("\n");
-		acpi_print_apic(madt_apicp);
-		madt_apicp = (struct MADT_APIC *) ((char *)madt_apicp +
-		    madt_apicp->len);
-	}
+	acpi_walk_subtables(sdp, (madt + 1), acpi_print_madt);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_hpet(struct ACPIsdt *sdp)
+acpi_handle_hpet(ACPI_TABLE_HEADER *sdp)
 {
-	struct HPETbody *hpetp;
+	ACPI_TABLE_HPET *hpet;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	hpetp = (struct HPETbody *) sdp->body;
-	printf("\tHPET Number=%d\n", hpetp->hpet_number);
+	hpet = (ACPI_TABLE_HPET *)sdp;
+	printf("\tHPET Number=%d\n", hpet->Sequence);
 	printf("\tADDR=");
-	acpi_print_gas(&hpetp->genaddr);
-	printf("\tHW Rev=0x%x\n", hpetp->block_hwrev);
-	printf("\tComparitors=%d\n", hpetp->block_comparitors);
-	printf("\tCounter Size=%d\n", hpetp->block_counter_size);
+	acpi_print_gas(&hpet->Address);
+	printf("\tHW Rev=0x%x\n", hpet->Id & ACPI_HPET_ID_HARDWARE_REV_ID);
+	printf("\tComparators=%d\n", (hpet->Id & ACPI_HPET_ID_COMPARATORS) >>
+	    8);
+	printf("\tCounter Size=%d\n", hpet->Id & ACPI_HPET_ID_COUNT_SIZE_CAP ?
+	    1 : 0);
 	printf("\tLegacy IRQ routing capable={");
-	if (hpetp->block_legacy_capable)
+	if (hpet->Id & ACPI_HPET_ID_LEGACY_CAPABLE)
 		printf("TRUE}\n");
 	else
 		printf("FALSE}\n");
-	printf("\tPCI Vendor ID=0x%04x\n", hpetp->block_pcivendor);
-	printf("\tMinimal Tick=%d\n", hpetp->clock_tick);
+	printf("\tPCI Vendor ID=0x%04x\n", hpet->Id >> 16);
+	printf("\tMinimal Tick=%d\n", hpet->MinimumTick);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_ecdt(struct ACPIsdt *sdp)
+acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp)
 {
-	struct ECDTbody *ecdt;
+	ACPI_TABLE_ECDT *ecdt;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	ecdt = (struct ECDTbody *) sdp->body;
+	ecdt = (ACPI_TABLE_ECDT *)sdp;
 	printf("\tEC_CONTROL=");
-	acpi_print_gas(&ecdt->ec_control);
+	acpi_print_gas(&ecdt->Control);
 	printf("\n\tEC_DATA=");
-	acpi_print_gas(&ecdt->ec_data);
-	printf("\n\tUID=%#x, ", ecdt->uid);
-	printf("GPE_BIT=%#x\n", ecdt->gpe_bit);
-	printf("\tEC_ID=%s\n", ecdt->ec_id);
+	acpi_print_gas(&ecdt->Data);
+	printf("\n\tUID=%#x, ", ecdt->Uid);
+	printf("GPE_BIT=%#x\n", ecdt->Gpe);
+	printf("\tEC_ID=%s\n", ecdt->Id);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_handle_mcfg(struct ACPIsdt *sdp)
+acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp)
 {
-	struct MCFGbody *mcfg;
-	u_int i, e;
+	ACPI_TABLE_MCFG *mcfg;
+	ACPI_MCFG_ALLOCATION *alloc;
+	u_int i, entries;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	mcfg = (struct MCFGbody *) sdp->body;
-
-	e = (sdp->len - ((caddr_t)&mcfg->s[0] - (caddr_t)sdp)) /
-	    sizeof(*mcfg->s);
-	for (i = 0; i < e; i++, mcfg++) {
+	mcfg = (ACPI_TABLE_MCFG *)sdp;
+	entries = (sdp->Length - sizeof(ACPI_TABLE_MCFG)) /
+	    sizeof(ACPI_MCFG_ALLOCATION);
+	alloc = (ACPI_MCFG_ALLOCATION *)(mcfg + 1);
+	for (i = 0; i < entries; i++, alloc++) {
 		printf("\n");
-		printf("\tBase Address=0x%016jx\n", mcfg->s[i].baseaddr);
-		printf("\tSegment Group=0x%04x\n", mcfg->s[i].seg_grp);
-		printf("\tStart Bus=%d\n", mcfg->s[i].start);
-		printf("\tEnd Bus=%d\n", mcfg->s[i].end);
+		printf("\tBase Address=0x%016jx\n", alloc->Address);
+		printf("\tSegment Group=0x%04x\n", alloc->PciSegment);
+		printf("\tStart Bus=%d\n", alloc->StartBusNumber);
+		printf("\tEnd Bus=%d\n", alloc->EndBusNumber);
 	}
 	printf(END_COMMENT);
 }
@@ -421,108 +478,103 @@ acpi_print_srat_cpu(uint32_t apic_id, ui
 }
 
 static void
-acpi_print_srat_memory(struct SRAT_memory *mp)
+acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp)
 {
 
 	printf("\tFlags={");
-	if (mp->flags & ACPI_SRAT_MEM_ENABLED)
+	if (mp->Flags & ACPI_SRAT_MEM_ENABLED)
 		printf("ENABLED");
 	else
 		printf("DISABLED");
-	if (mp->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
+	if (mp->Flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
 		printf(",HOT_PLUGGABLE");
-	if (mp->flags & ACPI_SRAT_MEM_NON_VOLATILE)
+	if (mp->Flags & ACPI_SRAT_MEM_NON_VOLATILE)
 		printf(",NON_VOLATILE");
 	printf("}\n");
-	printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->base_address);
-	printf("\tLength=0x%016jx\n", (uintmax_t)mp->length);
-	printf("\tProximity Domain=%d\n", mp->proximity_domain);
+	printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->BaseAddress);
+	printf("\tLength=0x%016jx\n", (uintmax_t)mp->Length);
+	printf("\tProximity Domain=%d\n", mp->ProximityDomain);
 }
 
-const char *srat_types[] = { "CPU", "Memory", "X2APIC" };
+const char *srat_types[] = { "CPU", "Memory" };
 
 static void
-acpi_print_srat(struct SRATentry *srat)
+acpi_print_srat(ACPI_SUBTABLE_HEADER *srat)
 {
+	ACPI_SRAT_CPU_AFFINITY *cpu;
 
-	if (srat->type < sizeof(srat_types) / sizeof(srat_types[0]))
-		printf("\tType=%s\n", srat_types[srat->type]);
+	if (srat->Type < sizeof(srat_types) / sizeof(srat_types[0]))
+		printf("\tType=%s\n", srat_types[srat->Type]);
 	else
-		printf("\tType=%d (unknown)\n", srat->type);
-	switch (srat->type) {
+		printf("\tType=%d (unknown)\n", srat->Type);
+	switch (srat->Type) {
 	case ACPI_SRAT_TYPE_CPU_AFFINITY:
-		acpi_print_srat_cpu(srat->body.cpu.apic_id,
-		    srat->body.cpu.proximity_domain_hi[2] << 24 |
-		    srat->body.cpu.proximity_domain_hi[1] << 16 |
-		    srat->body.cpu.proximity_domain_hi[0] << 0 |
-		    srat->body.cpu.proximity_domain_lo, srat->body.cpu.flags);
+		cpu = (ACPI_SRAT_CPU_AFFINITY *)srat;
+		acpi_print_srat_cpu(cpu->ApicId,
+		    cpu->ProximityDomainHi[2] << 24 |
+		    cpu->ProximityDomainHi[1] << 16 |
+		    cpu->ProximityDomainHi[0] << 0 |
+		    cpu->ProximityDomainLo, cpu->Flags);
 		break;
 	case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
-		acpi_print_srat_memory(&srat->body.mem);
-		break;
-	case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
-		acpi_print_srat_cpu(srat->body.x2apic.apic_id,
-		    srat->body.x2apic.proximity_domain,
-		    srat->body.x2apic.flags);
+		acpi_print_srat_memory((ACPI_SRAT_MEM_AFFINITY *)srat);
 		break;
 	}
 }
 
 static void
-acpi_handle_srat(struct ACPIsdt *sdp)
+acpi_handle_srat(ACPI_TABLE_HEADER *sdp)
 {
-	struct SRATbody *sratp;
-	struct SRATentry *entry;
+	ACPI_TABLE_SRAT *srat;
 
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	sratp = (struct SRATbody *)sdp->body;
-	printf("\tTable Revision=%d\n", sratp->table_revision);
-	entry = sratp->body;
-	while (((uintptr_t)entry) - ((uintptr_t)sdp) < sdp->len) {
-		printf("\n");
-		acpi_print_srat(entry);
-		entry = (struct SRATentry *)((char *)entry + entry->len);
-	}
+	srat = (ACPI_TABLE_SRAT *)sdp;
+	printf("\tTable Revision=%d\n", srat->TableRevision);
+	acpi_walk_subtables(sdp, (srat + 1), acpi_print_srat);
 	printf(END_COMMENT);
 }
 
 static void
-acpi_print_sdt(struct ACPIsdt *sdp)
+acpi_print_sdt(ACPI_TABLE_HEADER *sdp)
 {
 	printf("  ");
-	acpi_print_string(sdp->signature, 4);
+	acpi_print_string(sdp->Signature, ACPI_NAME_SIZE);
 	printf(": Length=%d, Revision=%d, Checksum=%d,\n",
-	       sdp->len, sdp->rev, sdp->check);
+	       sdp->Length, sdp->Revision, sdp->Checksum);
 	printf("\tOEMID=");
-	acpi_print_string(sdp->oemid, 6);
+	acpi_print_string(sdp->OemId, ACPI_OEM_ID_SIZE);
 	printf(", OEM Table ID=");
-	acpi_print_string(sdp->oemtblid, 8);
-	printf(", OEM Revision=0x%x,\n", sdp->oemrev);
+	acpi_print_string(sdp->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
+	printf(", OEM Revision=0x%x,\n", sdp->OemRevision);
 	printf("\tCreator ID=");
-	acpi_print_string(sdp->creator, 4);
-	printf(", Creator Revision=0x%x\n", sdp->crerev);
+	acpi_print_string(sdp->AslCompilerId, ACPI_NAME_SIZE);
+	printf(", Creator Revision=0x%x\n", sdp->AslCompilerRevision);
 }
 
 static void
-acpi_print_rsdt(struct ACPIsdt *rsdp)
+acpi_print_rsdt(ACPI_TABLE_HEADER *rsdp)
 {
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
 	int	i, entries;
 	u_long	addr;
 
+	rsdt = (ACPI_TABLE_RSDT *)rsdp;
+	xsdt = (ACPI_TABLE_XSDT *)rsdp;
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(rsdp);
-	entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size;
+	entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size;
 	printf("\tEntries={ ");
 	for (i = 0; i < entries; i++) {
 		if (i > 0)
 			printf(", ");
 		switch (addr_size) {
 		case 4:
-			addr = le32dec((char*)rsdp->body + i * addr_size);
+			addr = le32toh(rsdt->TableOffsetEntry[i]);
 			break;
 		case 8:
-			addr = le64dec((char*)rsdp->body + i * addr_size);
+			addr = le64toh(xsdt->TableOffsetEntry[i]);
 			break;
 		default:
 			addr = 0;
@@ -540,138 +592,151 @@ static const char *acpi_pm_profiles[] = 
 };
 
 static void
-acpi_print_fadt(struct ACPIsdt *sdp)
+acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
 {
-	struct FADTbody *fadt;
+	ACPI_TABLE_FADT *fadt;
 	const char *pm;
 	char	    sep;
 
-	fadt = (struct FADTbody *)sdp->body;
+	fadt = (ACPI_TABLE_FADT *)sdp;
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(sdp);
-	printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->facs_ptr,
-	       fadt->dsdt_ptr);
-	printf("\tINT_MODEL=%s\n", fadt->int_model ? "APIC" : "PIC");
-	if (fadt->pm_profile >= sizeof(acpi_pm_profiles) / sizeof(char *))
+	printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->Facs,
+	       fadt->Dsdt);
+	printf("\tINT_MODEL=%s\n", fadt->Model ? "APIC" : "PIC");
+	if (fadt->PreferredProfile >= sizeof(acpi_pm_profiles) / sizeof(char *))
 		pm = "Reserved";
 	else
-		pm = acpi_pm_profiles[fadt->pm_profile];
-	printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->pm_profile);
-	printf("\tSCI_INT=%d\n", fadt->sci_int);
-	printf("\tSMI_CMD=0x%x, ", fadt->smi_cmd);
-	printf("ACPI_ENABLE=0x%x, ", fadt->acpi_enable);
-	printf("ACPI_DISABLE=0x%x, ", fadt->acpi_disable);
-	printf("S4BIOS_REQ=0x%x\n", fadt->s4biosreq);
-	printf("\tPSTATE_CNT=0x%x\n", fadt->pstate_cnt);
+		pm = acpi_pm_profiles[fadt->PreferredProfile];
+	printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->PreferredProfile);
+	printf("\tSCI_INT=%d\n", fadt->SciInterrupt);
+	printf("\tSMI_CMD=0x%x, ", fadt->SmiCommand);
+	printf("ACPI_ENABLE=0x%x, ", fadt->AcpiEnable);
+	printf("ACPI_DISABLE=0x%x, ", fadt->AcpiDisable);
+	printf("S4BIOS_REQ=0x%x\n", fadt->S4BiosRequest);
+	printf("\tPSTATE_CNT=0x%x\n", fadt->PstateControl);
 	printf("\tPM1a_EVT_BLK=0x%x-0x%x\n",
-	       fadt->pm1a_evt_blk,
-	       fadt->pm1a_evt_blk + fadt->pm1_evt_len - 1);
-	if (fadt->pm1b_evt_blk != 0)
+	       fadt->Pm1aEventBlock,
+	       fadt->Pm1aEventBlock + fadt->Pm1EventLength - 1);
+	if (fadt->Pm1bEventBlock != 0)
 		printf("\tPM1b_EVT_BLK=0x%x-0x%x\n",
-		       fadt->pm1b_evt_blk,
-		       fadt->pm1b_evt_blk + fadt->pm1_evt_len - 1);
+		       fadt->Pm1bEventBlock,
+		       fadt->Pm1bEventBlock + fadt->Pm1EventLength - 1);
 	printf("\tPM1a_CNT_BLK=0x%x-0x%x\n",
-	       fadt->pm1a_cnt_blk,
-	       fadt->pm1a_cnt_blk + fadt->pm1_cnt_len - 1);
-	if (fadt->pm1b_cnt_blk != 0)
+	       fadt->Pm1aControlBlock,
+	       fadt->Pm1aControlBlock + fadt->Pm1ControlLength - 1);
+	if (fadt->Pm1bControlBlock != 0)
 		printf("\tPM1b_CNT_BLK=0x%x-0x%x\n",
-		       fadt->pm1b_cnt_blk,
-		       fadt->pm1b_cnt_blk + fadt->pm1_cnt_len - 1);
-	if (fadt->pm2_cnt_blk != 0)
+		       fadt->Pm1bControlBlock,
+		       fadt->Pm1bControlBlock + fadt->Pm1ControlLength - 1);
+	if (fadt->Pm2ControlBlock != 0)
 		printf("\tPM2_CNT_BLK=0x%x-0x%x\n",
-		       fadt->pm2_cnt_blk,
-		       fadt->pm2_cnt_blk + fadt->pm2_cnt_len - 1);
+		       fadt->Pm2ControlBlock,
+		       fadt->Pm2ControlBlock + fadt->Pm2ControlLength - 1);
 	printf("\tPM_TMR_BLK=0x%x-0x%x\n",
-	       fadt->pm_tmr_blk,
-	       fadt->pm_tmr_blk + fadt->pm_tmr_len - 1);
-	if (fadt->gpe0_blk != 0)
+	       fadt->PmTimerBlock,
+	       fadt->PmTimerBlock + fadt->PmTimerLength - 1);
+	if (fadt->Gpe0Block != 0)
 		printf("\tGPE0_BLK=0x%x-0x%x\n",
-		       fadt->gpe0_blk,
-		       fadt->gpe0_blk + fadt->gpe0_len - 1);
-	if (fadt->gpe1_blk != 0)
+		       fadt->Gpe0Block,
+		       fadt->Gpe0Block + fadt->Gpe0BlockLength - 1);
+	if (fadt->Gpe1Block != 0)
 		printf("\tGPE1_BLK=0x%x-0x%x, GPE1_BASE=%d\n",
-		       fadt->gpe1_blk,
-		       fadt->gpe1_blk + fadt->gpe1_len - 1,
-		       fadt->gpe1_base);
-	if (fadt->cst_cnt != 0)
-		printf("\tCST_CNT=0x%x\n", fadt->cst_cnt);
+		       fadt->Gpe1Block,
+		       fadt->Gpe1Block + fadt->Gpe1BlockLength - 1,
+		       fadt->Gpe1Base);
+	if (fadt->CstControl != 0)
+		printf("\tCST_CNT=0x%x\n", fadt->CstControl);
 	printf("\tP_LVL2_LAT=%d us, P_LVL3_LAT=%d us\n",
-	       fadt->p_lvl2_lat, fadt->p_lvl3_lat);
+	       fadt->C2Latency, fadt->C3Latency);
 	printf("\tFLUSH_SIZE=%d, FLUSH_STRIDE=%d\n",
-	       fadt->flush_size, fadt->flush_stride);
+	       fadt->FlushSize, fadt->FlushStride);
 	printf("\tDUTY_OFFSET=%d, DUTY_WIDTH=%d\n",
-	       fadt->duty_off, fadt->duty_width);
+	       fadt->DutyOffset, fadt->DutyWidth);
 	printf("\tDAY_ALRM=%d, MON_ALRM=%d, CENTURY=%d\n",
-	       fadt->day_alrm, fadt->mon_alrm, fadt->century);
+	       fadt->DayAlarm, fadt->MonthAlarm, fadt->Century);
 
 #define PRINTFLAG(var, flag) do {			\
-	if ((var) & FADT_FLAG_## flag) {		\
+	if ((var) & BAF_## flag) {			\
 		printf("%c%s", sep, #flag); sep = ',';	\
 	}						\
 } while (0)
 
 	printf("\tIAPC_BOOT_ARCH=");
 	sep = '{';
-	PRINTFLAG(fadt->iapc_boot_arch, LEGACY_DEV);
-	PRINTFLAG(fadt->iapc_boot_arch, 8042);
-	if (fadt->iapc_boot_arch != 0)
+	PRINTFLAG(fadt->BootFlags, LEGACY_DEVICES);
+	PRINTFLAG(fadt->BootFlags, 8042_KEYBOARD_CONTROLLER);
+	if (fadt->BootFlags != 0)
 		printf("}");
 	printf("\n");
 
+#undef PRINTFLAG
+#define PRINTFLAG(var, flag) do {			\
+	if ((var) & ACPI_FADT_## flag) {		\
+		printf("%c%s", sep, #flag); sep = ',';	\
+	}						\
+} while (0)
+
 	printf("\tFlags=");
 	sep = '{';
-	PRINTFLAG(fadt->flags, WBINVD);
-	PRINTFLAG(fadt->flags, WBINVD_FLUSH);
-	PRINTFLAG(fadt->flags, PROC_C1);
-	PRINTFLAG(fadt->flags, P_LVL2_UP);
-	PRINTFLAG(fadt->flags, PWR_BUTTON);
-	PRINTFLAG(fadt->flags, SLP_BUTTON);
-	PRINTFLAG(fadt->flags, FIX_RTC);
-	PRINTFLAG(fadt->flags, RTC_S4);
-	PRINTFLAG(fadt->flags, TMR_VAL_EXT);
-	PRINTFLAG(fadt->flags, DCK_CAP);
-	PRINTFLAG(fadt->flags, RESET_REG);
-	PRINTFLAG(fadt->flags, SEALED_CASE);
-	PRINTFLAG(fadt->flags, HEADLESS);
-	PRINTFLAG(fadt->flags, CPU_SW_SLP);
-	if (fadt->flags != 0)
+	PRINTFLAG(fadt->Flags, WBINVD);
+	PRINTFLAG(fadt->Flags, WBINVD_FLUSH);
+	PRINTFLAG(fadt->Flags, C1_SUPPORTED);
+	PRINTFLAG(fadt->Flags, C2_MP_SUPPORTED);
+	PRINTFLAG(fadt->Flags, POWER_BUTTON);
+	PRINTFLAG(fadt->Flags, SLEEP_BUTTON);
+	PRINTFLAG(fadt->Flags, FIXED_RTC);
+	PRINTFLAG(fadt->Flags, S4_RTC_WAKE);
+	PRINTFLAG(fadt->Flags, 32BIT_TIMER);
+	PRINTFLAG(fadt->Flags, DOCKING_SUPPORTED);
+	PRINTFLAG(fadt->Flags, RESET_REGISTER);
+	PRINTFLAG(fadt->Flags, SEALED_CASE);
+	PRINTFLAG(fadt->Flags, HEADLESS);
+	PRINTFLAG(fadt->Flags, SLEEP_TYPE);
+	PRINTFLAG(fadt->Flags, PCI_EXPRESS_WAKE);
+	PRINTFLAG(fadt->Flags, PLATFORM_CLOCK);
+	PRINTFLAG(fadt->Flags, S4_RTC_VALID);
+	PRINTFLAG(fadt->Flags, REMOTE_POWER_ON);
+	PRINTFLAG(fadt->Flags, APIC_CLUSTER);
+	PRINTFLAG(fadt->Flags, APIC_PHYSICAL);
+	if (fadt->Flags != 0)
 		printf("}\n");
 
 #undef PRINTFLAG
 
-	if (fadt->flags & FADT_FLAG_RESET_REG) {
+	if (fadt->Flags & ACPI_FADT_RESET_REGISTER) {
 		printf("\tRESET_REG=");
-		acpi_print_gas(&fadt->reset_reg);
-		printf(", RESET_VALUE=%#x\n", fadt->reset_value);
+		acpi_print_gas(&fadt->ResetRegister);
+		printf(", RESET_VALUE=%#x\n", fadt->ResetValue);
 	}
 	if (acpi_get_fadt_revision(fadt) > 1) {
-		printf("\tX_FACS=0x%08lx, ", (u_long)fadt->x_facs_ptr);
-		printf("X_DSDT=0x%08lx\n", (u_long)fadt->x_dsdt_ptr);
+		printf("\tX_FACS=0x%08lx, ", (u_long)fadt->XFacs);
+		printf("X_DSDT=0x%08lx\n", (u_long)fadt->XDsdt);
 		printf("\tX_PM1a_EVT_BLK=");
-		acpi_print_gas(&fadt->x_pm1a_evt_blk);
-		if (fadt->x_pm1b_evt_blk.address != 0) {
+		acpi_print_gas(&fadt->XPm1aEventBlock);
+		if (fadt->XPm1bEventBlock.Address != 0) {
 			printf("\n\tX_PM1b_EVT_BLK=");
-			acpi_print_gas(&fadt->x_pm1b_evt_blk);
+			acpi_print_gas(&fadt->XPm1bEventBlock);
 		}
 		printf("\n\tX_PM1a_CNT_BLK=");
-		acpi_print_gas(&fadt->x_pm1a_cnt_blk);
-		if (fadt->x_pm1b_cnt_blk.address != 0) {
+		acpi_print_gas(&fadt->XPm1aControlBlock);
+		if (fadt->XPm1bControlBlock.Address != 0) {
 			printf("\n\tX_PM1b_CNT_BLK=");
-			acpi_print_gas(&fadt->x_pm1b_cnt_blk);
+			acpi_print_gas(&fadt->XPm1bControlBlock);
 		}
-		if (fadt->x_pm1b_cnt_blk.address != 0) {
+		if (fadt->XPm2ControlBlock.Address != 0) {
 			printf("\n\tX_PM2_CNT_BLK=");
-			acpi_print_gas(&fadt->x_pm2_cnt_blk);
+			acpi_print_gas(&fadt->XPm2ControlBlock);
 		}
 		printf("\n\tX_PM_TMR_BLK=");
-		acpi_print_gas(&fadt->x_pm_tmr_blk);
-		if (fadt->x_gpe0_blk.address != 0) {
+		acpi_print_gas(&fadt->XPmTimerBlock);
+		if (fadt->XGpe0Block.Address != 0) {
 			printf("\n\tX_GPE0_BLK=");
-			acpi_print_gas(&fadt->x_gpe0_blk);
+			acpi_print_gas(&fadt->XGpe0Block);
 		}
-		if (fadt->x_gpe1_blk.address != 0) {
+		if (fadt->XGpe1Block.Address != 0) {
 			printf("\n\tX_GPE1_BLK=");
-			acpi_print_gas(&fadt->x_gpe1_blk);
+			acpi_print_gas(&fadt->XGpe1Block);
 		}
 		printf("\n");
 	}
@@ -680,38 +745,38 @@ acpi_print_fadt(struct ACPIsdt *sdp)
 }
 
 static void
-acpi_print_facs(struct FACSbody *facs)
+acpi_print_facs(ACPI_TABLE_FACS *facs)
 {
 	printf(BEGIN_COMMENT);
-	printf("  FACS:\tLength=%u, ", facs->len);
-	printf("HwSig=0x%08x, ", facs->hw_sig);
-	printf("Firm_Wake_Vec=0x%08x\n", facs->firm_wake_vec);
+	printf("  FACS:\tLength=%u, ", facs->Length);
+	printf("HwSig=0x%08x, ", facs->HardwareSignature);
+	printf("Firm_Wake_Vec=0x%08x\n", facs->FirmwareWakingVector);
 
 	printf("\tGlobal_Lock=");
-	if (facs->global_lock != 0) {
-		if (facs->global_lock & FACS_FLAG_LOCK_PENDING)
+	if (facs->GlobalLock != 0) {
+		if (facs->GlobalLock & ACPI_GLOCK_PENDING)
 			printf("PENDING,");
-		if (facs->global_lock & FACS_FLAG_LOCK_OWNED)
+		if (facs->GlobalLock & ACPI_GLOCK_OWNED)
 			printf("OWNED");
 	}
 	printf("\n");
 
 	printf("\tFlags=");
-	if (facs->flags & FACS_FLAG_S4BIOS_F)
+	if (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT)
 		printf("S4BIOS");
 	printf("\n");
 
-	if (facs->x_firm_wake_vec != 0) {
+	if (facs->XFirmwareWakingVector != 0) {
 		printf("\tX_Firm_Wake_Vec=%08lx\n",
-		       (u_long)facs->x_firm_wake_vec);
+		       (u_long)facs->XFirmwareWakingVector);
 	}
-	printf("\tVersion=%u\n", facs->version);
+	printf("\tVersion=%u\n", facs->Version);
 
 	printf(END_COMMENT);
 }
 
 static void
-acpi_print_dsdt(struct ACPIsdt *dsdp)
+acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp)
 {
 	printf(BEGIN_COMMENT);
 	acpi_print_sdt(dsdp);
@@ -721,8 +786,8 @@ acpi_print_dsdt(struct ACPIsdt *dsdp)
 int
 acpi_checksum(void *p, size_t length)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:09:55 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 76E5D106568B;
	Thu, 29 Oct 2009 15:09:55 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2E52E8FC16;
	Thu, 29 Oct 2009 15:09:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TF9toQ000456;
	Thu, 29 Oct 2009 15:09:55 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TF9s7L000450;
	Thu, 29 Oct 2009 15:09:54 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291509.n9TF9s7L000450@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:09:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198594 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci kern sys vm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:09:55 -0000

Author: jhb
Date: Thu Oct 29 15:09:54 2009
New Revision: 198594
URL: http://svn.freebsd.org/changeset/base/198594

Log:
  MFC 196615:
  Extend the device pager to support different memory attributes on different
  pages in an object.
  - Add a new variant of d_mmap() currently called d_mmap2() which accepts
    an additional in/out parameter that is the memory attribute to use for
    the requested page.
  - A driver either uses d_mmap() or d_mmap2() for all requests but not both.
    The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
    that the driver provides a d_mmap2() handler instead of d_mmap().  This
    is done to make the change ABI compatible with existing drivers and
    MFC'able to 7 and 8.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/kern_conf.c
  stable/8/sys/sys/conf.h
  stable/8/sys/sys/types.h
  stable/8/sys/vm/device_pager.c
  stable/8/sys/vm/vm.h

Modified: stable/8/sys/kern/kern_conf.c
==============================================================================
--- stable/8/sys/kern/kern_conf.c	Thu Oct 29 14:53:45 2009	(r198593)
+++ stable/8/sys/kern/kern_conf.c	Thu Oct 29 15:09:54 2009	(r198594)
@@ -302,7 +302,7 @@ static struct cdevsw dead_cdevsw = {
 #define no_read		(d_read_t *)enodev
 #define no_write	(d_write_t *)enodev
 #define no_ioctl	(d_ioctl_t *)enodev
-#define no_mmap		(d_mmap_t *)enodev
+#define no_mmap		(d_mmap2_t *)enodev
 #define no_kqfilter	(d_kqfilter_t *)enodev
 #define no_mmap_single	(d_mmap_single_t *)enodev
 
@@ -469,7 +469,8 @@ giant_kqfilter(struct cdev *dev, struct 
 }
 
 static int
-giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
+giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot,
+    vm_memattr_t *memattr)
 {
 	struct cdevsw *dsw;
 	int retval;
@@ -478,7 +479,11 @@ giant_mmap(struct cdev *dev, vm_offset_t
 	if (dsw == NULL)
 		return (ENXIO);
 	mtx_lock(&Giant);
-	retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
+	if (dsw->d_gianttrick->d_flags & D_MMAP2)
+		retval = dsw->d_gianttrick->d_mmap2(dev, offset, paddr, nprot,
+		    memattr);
+	else
+		retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
 	mtx_unlock(&Giant);
 	dev_relthread(dev);
 	return (retval);
@@ -614,6 +619,7 @@ prep_cdevsw(struct cdevsw *devsw)
 		if (devsw->d_gianttrick == NULL) {
 			memcpy(dsw2, devsw, sizeof *dsw2);
 			devsw->d_gianttrick = dsw2;
+			devsw->d_flags |= D_MMAP2;
 			dsw2 = NULL;
 		}
 	}
@@ -634,7 +640,7 @@ prep_cdevsw(struct cdevsw *devsw)
 	FIXUP(d_write,		no_write,	giant_write);
 	FIXUP(d_ioctl,		no_ioctl,	giant_ioctl);
 	FIXUP(d_poll,		no_poll,	giant_poll);
-	FIXUP(d_mmap,		no_mmap,	giant_mmap);
+	FIXUP(d_mmap2,		no_mmap,	giant_mmap);
 	FIXUP(d_strategy,	no_strategy,	giant_strategy);
 	FIXUP(d_kqfilter,	no_kqfilter,	giant_kqfilter);
 	FIXUP(d_mmap_single,	no_mmap_single,	giant_mmap_single);

Modified: stable/8/sys/sys/conf.h
==============================================================================
--- stable/8/sys/sys/conf.h	Thu Oct 29 14:53:45 2009	(r198593)
+++ stable/8/sys/sys/conf.h	Thu Oct 29 15:09:54 2009	(r198594)
@@ -137,6 +137,8 @@ typedef int d_poll_t(struct cdev *dev, i
 typedef int d_kqfilter_t(struct cdev *dev, struct knote *kn);
 typedef int d_mmap_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
    		     int nprot);
+typedef int d_mmap2_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
+		     int nprot, vm_memattr_t *memattr);
 typedef int d_mmap_single_t(struct cdev *cdev, vm_ooffset_t *offset,
     vm_size_t size, struct vm_object **object, int nprot);
 typedef void d_purge_t(struct cdev *dev);
@@ -170,6 +172,7 @@ typedef int dumper_t(
 #define D_PSEUDO	0x00200000	/* make_dev() can return NULL */
 #define D_NEEDGIANT	0x00400000	/* driver want Giant */
 #define	D_NEEDMINOR	0x00800000	/* driver uses clone_create() */
+#define	D_MMAP2		0x01000000	/* driver uses d_mmap2() */
 
 /*
  * Version numbers.
@@ -198,7 +201,10 @@ struct cdevsw {
 	d_write_t		*d_write;
 	d_ioctl_t		*d_ioctl;
 	d_poll_t		*d_poll;
-	d_mmap_t		*d_mmap;
+	union {
+		d_mmap_t		*old;
+		d_mmap2_t		*new;
+	} __d_mmap;
 	d_strategy_t		*d_strategy;
 	dumper_t		*d_dump;
 	d_kqfilter_t		*d_kqfilter;
@@ -218,6 +224,8 @@ struct cdevsw {
 		SLIST_ENTRY(cdevsw)	postfree_list;
 	} __d_giant;
 };
+#define	d_mmap			__d_mmap.old
+#define	d_mmap2			__d_mmap.new
 #define	d_gianttrick		__d_giant.gianttrick
 #define	d_postfree_list		__d_giant.postfree_list
 

Modified: stable/8/sys/sys/types.h
==============================================================================
--- stable/8/sys/sys/types.h	Thu Oct 29 14:53:45 2009	(r198593)
+++ stable/8/sys/sys/types.h	Thu Oct 29 15:09:54 2009	(r198594)
@@ -299,6 +299,7 @@ typedef	__uint32_t	intrmask_t;	/* Interr
 
 typedef	__uintfptr_t	uintfptr_t;
 typedef	__uint64_t	uoff_t;
+typedef	char		vm_memattr_t;	/* memory attribute codes */
 typedef	struct vm_page	*vm_page_t;
 
 #define offsetof(type, field) __offsetof(type, field)

Modified: stable/8/sys/vm/device_pager.c
==============================================================================
--- stable/8/sys/vm/device_pager.c	Thu Oct 29 14:53:45 2009	(r198593)
+++ stable/8/sys/vm/device_pager.c	Thu Oct 29 15:09:54 2009	(r198594)
@@ -93,6 +93,17 @@ dev_pager_init()
 	    UMA_ZONE_NOFREE|UMA_ZONE_VM); 
 }
 
+static __inline int
+dev_mmap(struct cdevsw *csw, struct cdev *dev, vm_offset_t offset,
+    vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr)
+{
+
+	if (csw->d_flags & D_MMAP2)
+		return (csw->d_mmap2(dev, offset, paddr, nprot, memattr));
+	else
+		return (csw->d_mmap(dev, offset, paddr, nprot));
+}
+
 /*
  * MPSAFE
  */
@@ -106,6 +117,7 @@ dev_pager_alloc(void *handle, vm_ooffset
 	unsigned int npages;
 	vm_paddr_t paddr;
 	vm_offset_t off;
+	vm_memattr_t dummy;
 	struct cdevsw *csw;
 
 	/*
@@ -133,7 +145,7 @@ dev_pager_alloc(void *handle, vm_ooffset
 	 */
 	npages = OFF_TO_IDX(size);
 	for (off = foff; npages--; off += PAGE_SIZE)
-		if ((*csw->d_mmap)(dev, off, &paddr, (int)prot) != 0) {
+		if (dev_mmap(csw, dev, off, &paddr, (int)prot, &dummy) != 0) {
 			dev_relthread(dev);
 			return (NULL);
 		}
@@ -214,7 +226,6 @@ dev_pager_getpages(object, m, count, req
 	vm_memattr_t memattr;
 	struct cdev *dev;
 	int i, ret;
-	int prot;
 	struct cdevsw *csw;
 	struct thread *td;
 	struct file *fpop;
@@ -228,12 +239,11 @@ dev_pager_getpages(object, m, count, req
 	csw = dev_refthread(dev);
 	if (csw == NULL)
 		panic("dev_pager_getpage: no cdevsw");
-	prot = PROT_READ;	/* XXX should pass in? */
-
 	td = curthread;
 	fpop = td->td_fpop;
 	td->td_fpop = NULL;
-	ret = (*csw->d_mmap)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot);
+	ret = dev_mmap(csw, dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr,
+	    PROT_READ, &memattr);
 	KASSERT(ret == 0, ("dev_pager_getpage: map function returns error"));
 	td->td_fpop = fpop;
 	dev_relthread(dev);

Modified: stable/8/sys/vm/vm.h
==============================================================================
--- stable/8/sys/vm/vm.h	Thu Oct 29 14:53:45 2009	(r198593)
+++ stable/8/sys/vm/vm.h	Thu Oct 29 15:09:54 2009	(r198594)
@@ -63,12 +63,6 @@
 
 #include 
 
-/*
- * The exact set of memory attributes is machine dependent.  However, every
- * machine is required to define VM_MEMATTR_DEFAULT.
- */
-typedef	char vm_memattr_t;	/* memory attribute codes */
-
 typedef char vm_inherit_t;	/* inheritance codes */
 
 #define	VM_INHERIT_SHARE	((vm_inherit_t) 0)
@@ -115,6 +109,12 @@ typedef struct vm_object *vm_object_t;
 typedef int boolean_t;
 
 /*
+ * The exact set of memory attributes is machine dependent.  However, every
+ * machine is required to define VM_MEMATTR_DEFAULT.
+ */
+typedef	char vm_memattr_t;	/* memory attribute codes */
+
+/*
  * This is defined in  for the kernel so that vnode_if.h
  * doesn't have to include .
  */

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:10:39 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 17D1210656A5;
	Thu, 29 Oct 2009 15:10:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 059D78FC2E;
	Thu, 29 Oct 2009 15:10:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFAcWM000518;
	Thu, 29 Oct 2009 15:10:38 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFAcNw000512;
	Thu, 29 Oct 2009 15:10:38 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291510.n9TFAcNw000512@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:10:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198595 - in stable/7/sys: . contrib/pf kern sys vm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:10:39 -0000

Author: jhb
Date: Thu Oct 29 15:10:38 2009
New Revision: 198595
URL: http://svn.freebsd.org/changeset/base/198595

Log:
  MFC 196615:
  Extend the device pager to support different memory attributes on different
  pages in an object.
  - Add a new variant of d_mmap() currently called d_mmap2() which accepts
    an additional in/out parameter that is the memory attribute to use for
    the requested page.
  - A driver either uses d_mmap() or d_mmap2() for all requests but not both.
    The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
    that the driver provides a d_mmap2() handler instead of d_mmap().  This
    is done to make the change ABI compatible with existing drivers and
    MFC'able to 7 and 8.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/kern_conf.c
  stable/7/sys/sys/conf.h
  stable/7/sys/sys/types.h
  stable/7/sys/vm/device_pager.c
  stable/7/sys/vm/vm.h

Modified: stable/7/sys/kern/kern_conf.c
==============================================================================
--- stable/7/sys/kern/kern_conf.c	Thu Oct 29 15:09:54 2009	(r198594)
+++ stable/7/sys/kern/kern_conf.c	Thu Oct 29 15:10:38 2009	(r198595)
@@ -303,7 +303,7 @@ static struct cdevsw dead_cdevsw = {
 #define no_read		(d_read_t *)enodev
 #define no_write	(d_write_t *)enodev
 #define no_ioctl	(d_ioctl_t *)enodev
-#define no_mmap		(d_mmap_t *)enodev
+#define no_mmap		(d_mmap2_t *)enodev
 #define no_kqfilter	(d_kqfilter_t *)enodev
 #define no_mmap_single	(d_mmap_single_t *)enodev
 
@@ -470,7 +470,8 @@ giant_kqfilter(struct cdev *dev, struct 
 }
 
 static int
-giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
+giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot,
+    vm_memattr_t *memattr)
 {
 	struct cdevsw *dsw;
 	int retval;
@@ -479,7 +480,11 @@ giant_mmap(struct cdev *dev, vm_offset_t
 	if (dsw == NULL)
 		return (ENXIO);
 	mtx_lock(&Giant);
-	retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
+	if (dsw->d_gianttrick->d_flags & D_MMAP2)
+		retval = dsw->d_gianttrick->d_mmap2(dev, offset, paddr, nprot,
+		    memattr);
+	else
+		retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
 	mtx_unlock(&Giant);
 	dev_relthread(dev);
 	return (retval);
@@ -669,6 +674,7 @@ prep_cdevsw(struct cdevsw *devsw)
 		if (devsw->d_gianttrick == NULL) {
 			memcpy(dsw2, devsw, sizeof *dsw2);
 			devsw->d_gianttrick = dsw2;
+			devsw->d_flags |= D_MMAP2;
 			dsw2 = NULL;
 		}
 	}
@@ -689,7 +695,7 @@ prep_cdevsw(struct cdevsw *devsw)
 	FIXUP(d_write,		no_write,	giant_write);
 	FIXUP(d_ioctl,		no_ioctl,	giant_ioctl);
 	FIXUP(d_poll,		no_poll,	giant_poll);
-	FIXUP(d_mmap,		no_mmap,	giant_mmap);
+	FIXUP(d_mmap2,		no_mmap,	giant_mmap);
 	FIXUP(d_strategy,	no_strategy,	giant_strategy);
 	FIXUP(d_kqfilter,	no_kqfilter,	giant_kqfilter);
 	FIXUP(d_mmap_single,	no_mmap_single,	giant_mmap_single);

Modified: stable/7/sys/sys/conf.h
==============================================================================
--- stable/7/sys/sys/conf.h	Thu Oct 29 15:09:54 2009	(r198594)
+++ stable/7/sys/sys/conf.h	Thu Oct 29 15:10:38 2009	(r198595)
@@ -140,6 +140,8 @@ typedef int d_poll_t(struct cdev *dev, i
 typedef int d_kqfilter_t(struct cdev *dev, struct knote *kn);
 typedef int d_mmap_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
    		     int nprot);
+typedef int d_mmap2_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
+		     int nprot, vm_memattr_t *memattr);
 typedef int d_mmap_single_t(struct cdev *cdev, vm_ooffset_t *offset,
     vm_size_t size, struct vm_object **object, int nprot);
 typedef void d_purge_t(struct cdev *dev);
@@ -172,6 +174,7 @@ typedef int dumper_t(
 #define D_MMAP_ANON	0x00100000	/* special treatment in vm_mmap.c */
 #define D_PSEUDO	0x00200000	/* make_dev() can return NULL */
 #define D_NEEDGIANT	0x00400000	/* driver want Giant */
+#define	D_MMAP2		0x01000000	/* driver uses d_mmap2() */
 
 /*
  * Version numbers.
@@ -200,7 +203,10 @@ struct cdevsw {
 	d_write_t		*d_write;
 	d_ioctl_t		*d_ioctl;
 	d_poll_t		*d_poll;
-	d_mmap_t		*d_mmap;
+	union {
+		d_mmap_t		*old;
+		d_mmap2_t		*new;
+	} __d_mmap;
 	d_strategy_t		*d_strategy;
 	dumper_t		*d_dump;
 	d_kqfilter_t		*d_kqfilter;
@@ -220,6 +226,8 @@ struct cdevsw {
 		SLIST_ENTRY(cdevsw)	postfree_list;
 	} __d_giant;
 };
+#define	d_mmap			__d_mmap.old
+#define	d_mmap2			__d_mmap.new
 #define	d_gianttrick		__d_giant.gianttrick
 #define	d_postfree_list		__d_giant.postfree_list
 

Modified: stable/7/sys/sys/types.h
==============================================================================
--- stable/7/sys/sys/types.h	Thu Oct 29 15:09:54 2009	(r198594)
+++ stable/7/sys/sys/types.h	Thu Oct 29 15:10:38 2009	(r198595)
@@ -299,6 +299,7 @@ typedef	__uint32_t	intrmask_t;	/* Interr
 
 typedef	__uintfptr_t	uintfptr_t;
 typedef	__uint64_t	uoff_t;
+typedef	char		vm_memattr_t;	/* memory attribute codes */
 typedef	struct vm_page	*vm_page_t;
 
 #define offsetof(type, field) __offsetof(type, field)

Modified: stable/7/sys/vm/device_pager.c
==============================================================================
--- stable/7/sys/vm/device_pager.c	Thu Oct 29 15:09:54 2009	(r198594)
+++ stable/7/sys/vm/device_pager.c	Thu Oct 29 15:10:38 2009	(r198595)
@@ -93,6 +93,17 @@ dev_pager_init()
 	    UMA_ZONE_NOFREE|UMA_ZONE_VM); 
 }
 
+static __inline int
+dev_mmap(struct cdevsw *csw, struct cdev *dev, vm_offset_t offset,
+    vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr)
+{
+
+	if (csw->d_flags & D_MMAP2)
+		return (csw->d_mmap2(dev, offset, paddr, nprot, memattr));
+	else
+		return (csw->d_mmap(dev, offset, paddr, nprot));
+}
+
 /*
  * MPSAFE
  */
@@ -105,6 +116,7 @@ dev_pager_alloc(void *handle, vm_ooffset
 	unsigned int npages;
 	vm_paddr_t paddr;
 	vm_offset_t off;
+	vm_memattr_t dummy;
 	struct cdevsw *csw;
 
 	/*
@@ -132,7 +144,7 @@ dev_pager_alloc(void *handle, vm_ooffset
 	 */
 	npages = OFF_TO_IDX(size);
 	for (off = foff; npages--; off += PAGE_SIZE)
-		if ((*csw->d_mmap)(dev, off, &paddr, (int)prot) != 0) {
+		if (dev_mmap(csw, dev, off, &paddr, (int)prot, &dummy) != 0) {
 			dev_relthread(dev);
 			return (NULL);
 		}
@@ -213,7 +225,6 @@ dev_pager_getpages(object, m, count, req
 	vm_memattr_t memattr;
 	struct cdev *dev;
 	int i, ret;
-	int prot;
 	struct cdevsw *csw;
 	struct thread *td;
 	struct file *fpop;
@@ -227,12 +238,11 @@ dev_pager_getpages(object, m, count, req
 	csw = dev_refthread(dev);
 	if (csw == NULL)
 		panic("dev_pager_getpage: no cdevsw");
-	prot = PROT_READ;	/* XXX should pass in? */
-
 	td = curthread;
 	fpop = td->td_fpop;
 	td->td_fpop = NULL;
-	ret = (*csw->d_mmap)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot);
+	ret = dev_mmap(csw, dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr,
+	    PROT_READ, &memattr);
 	KASSERT(ret == 0, ("dev_pager_getpage: map function returns error"));
 	td->td_fpop = fpop;
 	dev_relthread(dev);

Modified: stable/7/sys/vm/vm.h
==============================================================================
--- stable/7/sys/vm/vm.h	Thu Oct 29 15:09:54 2009	(r198594)
+++ stable/7/sys/vm/vm.h	Thu Oct 29 15:10:38 2009	(r198595)
@@ -63,12 +63,6 @@
 
 #include 
 
-/*
- * The exact set of memory attributes is machine dependent.  However, every
- * machine is required to define VM_MEMATTR_DEFAULT.
- */
-typedef	char vm_memattr_t;	/* memory attribute codes */
-
 typedef char vm_inherit_t;	/* inheritance codes */
 
 #define	VM_INHERIT_SHARE	((vm_inherit_t) 0)
@@ -115,6 +109,12 @@ typedef struct vm_object *vm_object_t;
 typedef int boolean_t;
 
 /*
+ * The exact set of memory attributes is machine dependent.  However, every
+ * machine is required to define VM_MEMATTR_DEFAULT.
+ */
+typedef	char vm_memattr_t;	/* memory attribute codes */
+
+/*
  * This is defined in  for the kernel so that vnode_if.h
  * doesn't have to include .
  */

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:13:36 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C212A106566B;
	Thu, 29 Oct 2009 15:13:36 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AFC6D8FC20;
	Thu, 29 Oct 2009 15:13:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFDalS000643;
	Thu, 29 Oct 2009 15:13:36 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFDai4000641;
	Thu, 29 Oct 2009 15:13:36 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291513.n9TFDai4000641@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:13:36 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198596 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/acpi_support dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:13:36 -0000

Author: jhb
Date: Thu Oct 29 15:13:36 2009
New Revision: 198596
URL: http://svn.freebsd.org/changeset/base/198596

Log:
  MFC 197460:
  Remove unnecessary locking from attach().  This fixes a LOR between the
  acpi_ibm lock and the sysctl lock.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/acpi_support/acpi_ibm.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/acpi_support/acpi_ibm.c
==============================================================================
--- stable/8/sys/dev/acpi_support/acpi_ibm.c	Thu Oct 29 15:10:38 2009	(r198595)
+++ stable/8/sys/dev/acpi_support/acpi_ibm.c	Thu Oct 29 15:13:36 2009	(r198596)
@@ -356,8 +356,6 @@ acpi_ibm_attach(device_t dev)
 	}
 	sc->ec_handle = acpi_get_handle(sc->ec_dev);
 
-	ACPI_SERIAL_BEGIN(ibm);
-
 	/* Get the sysctl tree */
 	sc->sysctl_ctx = device_get_sysctl_ctx(dev);
 	sc->sysctl_tree = device_get_sysctl_tree(dev);
@@ -404,8 +402,6 @@ acpi_ibm_attach(device_t dev)
 		    "Thermal zones");
 	}
 
-	ACPI_SERIAL_END(ibm);
-
 	/* Handle notifies */
 	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
 	    acpi_ibm_notify, dev);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:13:51 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4C8091065694;
	Thu, 29 Oct 2009 15:13:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3B2438FC08;
	Thu, 29 Oct 2009 15:13:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFDpla000683;
	Thu, 29 Oct 2009 15:13:51 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFDpk8000681;
	Thu, 29 Oct 2009 15:13:51 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291513.n9TFDpk8000681@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:13:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198597 - in stable/7/sys: . contrib/pf dev/acpi_support
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:13:51 -0000

Author: jhb
Date: Thu Oct 29 15:13:50 2009
New Revision: 198597
URL: http://svn.freebsd.org/changeset/base/198597

Log:
  MFC 197460:
  Remove unnecessary locking from attach().  This fixes a LOR between the
  acpi_ibm lock and the sysctl lock.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/acpi_support/acpi_ibm.c

Modified: stable/7/sys/dev/acpi_support/acpi_ibm.c
==============================================================================
--- stable/7/sys/dev/acpi_support/acpi_ibm.c	Thu Oct 29 15:13:36 2009	(r198596)
+++ stable/7/sys/dev/acpi_support/acpi_ibm.c	Thu Oct 29 15:13:50 2009	(r198597)
@@ -356,8 +356,6 @@ acpi_ibm_attach(device_t dev)
 	}
 	sc->ec_handle = acpi_get_handle(sc->ec_dev);
 
-	ACPI_SERIAL_BEGIN(ibm);
-
 	/* Get the sysctl tree */
 	sc->sysctl_ctx = device_get_sysctl_ctx(dev);
 	sc->sysctl_tree = device_get_sysctl_tree(dev);
@@ -404,8 +402,6 @@ acpi_ibm_attach(device_t dev)
 		    "Thermal zones");
 	}
 
-	ACPI_SERIAL_END(ibm);
-
 	/* Handle notifies */
 	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
 	    acpi_ibm_notify, dev);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:18:00 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5BC811065676;
	Thu, 29 Oct 2009 15:18:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3F4CB8FC14;
	Thu, 29 Oct 2009 15:18:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFI05P000849;
	Thu, 29 Oct 2009 15:18:00 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFI0DD000847;
	Thu, 29 Oct 2009 15:18:00 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291518.n9TFI0DD000847@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:18:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198598 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/cxgb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:18:00 -0000

Author: jhb
Date: Thu Oct 29 15:17:59 2009
New Revision: 198598
URL: http://svn.freebsd.org/changeset/base/198598

Log:
  MFC 196840:
  Fill the reverse RSS map with 0xff's so that the subsequent loop to
  calculate the values will work properly.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/cxgb/cxgb_main.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/cxgb/cxgb_main.c
==============================================================================
--- stable/8/sys/dev/cxgb/cxgb_main.c	Thu Oct 29 15:13:50 2009	(r198597)
+++ stable/8/sys/dev/cxgb/cxgb_main.c	Thu Oct 29 15:17:59 2009	(r198598)
@@ -1456,7 +1456,10 @@ setup_rss(adapter_t *adap)
 		rspq_map[i] = nq[0] ? i % nq[0] : 0;
 		rspq_map[i + RSS_TABLE_SIZE / 2] = nq[1] ? i % nq[1] + nq[0] : 0;
 	}
+
 	/* Calculate the reverse RSS map table */
+	for (i = 0; i < SGE_QSETS; ++i)
+		adap->rrss_map[i] = 0xff;
 	for (i = 0; i < RSS_TABLE_SIZE; ++i)
 		if (adap->rrss_map[rspq_map[i]] == 0xff)
 			adap->rrss_map[rspq_map[i]] = i;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:18:24 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B185010656A5;
	Thu, 29 Oct 2009 15:18:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A036A8FC0A;
	Thu, 29 Oct 2009 15:18:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFIOvm000897;
	Thu, 29 Oct 2009 15:18:24 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFIOD0000895;
	Thu, 29 Oct 2009 15:18:24 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291518.n9TFIOD0000895@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:18:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198599 - in stable/7/sys: . contrib/pf dev/cxgb
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:18:24 -0000

Author: jhb
Date: Thu Oct 29 15:18:24 2009
New Revision: 198599
URL: http://svn.freebsd.org/changeset/base/198599

Log:
  MFC 196840:
  Fill the reverse RSS map with 0xff's so that the subsequent loop to
  calculate the values will work properly.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/cxgb/cxgb_main.c

Modified: stable/7/sys/dev/cxgb/cxgb_main.c
==============================================================================
--- stable/7/sys/dev/cxgb/cxgb_main.c	Thu Oct 29 15:17:59 2009	(r198598)
+++ stable/7/sys/dev/cxgb/cxgb_main.c	Thu Oct 29 15:18:24 2009	(r198599)
@@ -1498,7 +1498,10 @@ setup_rss(adapter_t *adap)
 		rspq_map[i] = nq[0] ? i % nq[0] : 0;
 		rspq_map[i + RSS_TABLE_SIZE / 2] = nq[1] ? i % nq[1] + nq[0] : 0;
 	}
+
 	/* Calculate the reverse RSS map table */
+	for (i = 0; i < SGE_QSETS; ++i)
+		adap->rrss_map[i] = 0xff;
 	for (i = 0; i < RSS_TABLE_SIZE; ++i)
 		if (adap->rrss_map[rspq_map[i]] == 0xff)
 			adap->rrss_map[rspq_map[i]] = i;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:24:58 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 23F1E106568F;
	Thu, 29 Oct 2009 15:24:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 10DF38FC18;
	Thu, 29 Oct 2009 15:24:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFOvnl001105;
	Thu, 29 Oct 2009 15:24:57 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFOvB8001103;
	Thu, 29 Oct 2009 15:24:57 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291524.n9TFOvB8001103@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:24:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198600 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/acpica dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:24:58 -0000

Author: jhb
Date: Thu Oct 29 15:24:57 2009
New Revision: 198600
URL: http://svn.freebsd.org/changeset/base/198600

Log:
  MFC 197648:
  Split the 'video' ACPI lock up into two locks to resolve a LOR with the
  sysctl lock.  The 'video' lock now protects the 'bus' of video output
  devices attached to a graphics adapter.  It is used when iterating over
  the list of outputs, etc.  The 'video_output' lock is used to lock the
  output-specific data similar to a driver lock for the individual video
  outputs.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/acpica/acpi_video.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/acpica/acpi_video.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_video.c	Thu Oct 29 15:18:24 2009	(r198599)
+++ stable/8/sys/dev/acpica/acpi_video.c	Thu Oct 29 15:24:57 2009	(r198600)
@@ -170,7 +170,13 @@ static struct sysctl_oid	*acpi_video_sys
 static struct acpi_video_output_queue crt_units, tv_units,
     ext_units, lcd_units, other_units;
 
+/*
+ * The 'video' lock protects the hierarchy of video output devices
+ * (the video "bus").  The 'video_output' lock protects per-output
+ * data is equivalent to a softc lock for each video output.
+ */
 ACPI_SERIAL_DECL(video, "ACPI video");
+ACPI_SERIAL_DECL(video_output, "ACPI video output");
 MALLOC_DEFINE(M_ACPIVIDEO, "acpivideo", "ACPI video extension");
 
 static int
@@ -236,12 +242,14 @@ acpi_video_attach(device_t dev)
 	acpi_sc = devclass_get_softc(devclass_find("acpi"), 0);
 	if (acpi_sc == NULL)
 		return (ENXIO);
+	ACPI_SERIAL_BEGIN(video);
 	if (acpi_video_sysctl_tree == NULL) {
 		acpi_video_sysctl_tree = SYSCTL_ADD_NODE(&acpi_video_sysctl_ctx,
 				    SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree),
 				    OID_AUTO, "video", CTLFLAG_RD, 0,
 				    "video extension control");
 	}
+	ACPI_SERIAL_END(video);
 
 	sc->device = dev;
 	sc->handle = acpi_get_handle(dev);
@@ -317,6 +325,7 @@ acpi_video_notify_handler(ACPI_HANDLE ha
 		dss_p = 0;
 		lasthand = NULL;
 		ACPI_SERIAL_BEGIN(video);
+		ACPI_SERIAL_BEGIN(video_output);
 		STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) {
 			dss = vo_get_graphics_state(vo->handle);
 			dcs = vo_get_device_status(vo->handle);
@@ -332,6 +341,7 @@ acpi_video_notify_handler(ACPI_HANDLE ha
 		}
 		if (lasthand != NULL)
 			vo_set_device_state(lasthand, dss_p|DSS_COMMIT);
+		ACPI_SERIAL_END(video_output);
 		ACPI_SERIAL_END(video);
 		break;
 	case VID_NOTIFY_REPROBE:
@@ -368,12 +378,14 @@ acpi_video_power_profile(void *context)
 		return;
 
 	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) {
 		if (vo->vo_levels != NULL && vo->vo_brightness == -1)
 			vo_set_brightness(vo->handle,
 			    state == POWER_PROFILE_ECONOMY ?
 			    vo->vo_economy : vo->vo_fullpower);
 	}
+	ACPI_SERIAL_END(video_output);
 	ACPI_SERIAL_END(video);
 }
 
@@ -551,7 +563,7 @@ static void
 acpi_video_vo_bind(struct acpi_video_output *vo, ACPI_HANDLE handle)
 {
 
-	ACPI_SERIAL_ASSERT(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->vo_levels != NULL)
 		AcpiOsFree(vo->vo_levels);
 	vo->handle = handle;
@@ -566,6 +578,7 @@ acpi_video_vo_bind(struct acpi_video_out
 			/* XXX - see above. */
 			vo->vo_economy = vo->vo_levels[BCL_ECONOMY];
 	}
+	ACPI_SERIAL_END(video_output);
 }
 
 static void
@@ -606,7 +619,7 @@ acpi_video_vo_check_level(struct acpi_vi
 {
 	int i;
 
-	ACPI_SERIAL_ASSERT(video);
+	ACPI_SERIAL_ASSERT(video_output);
 	if (vo->vo_levels == NULL)
 		return (ENODEV);
 	for (i = 0; i < vo->vo_numlevels; i++)
@@ -625,7 +638,7 @@ acpi_video_vo_active_sysctl(SYSCTL_HANDL
 	vo = (struct acpi_video_output *)arg1;
 	if (vo->handle == NULL)
 		return (ENXIO);
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	state = (vo_get_device_status(vo->handle) & DCS_ACTIVE) ? 1 : 0;
 	err = sysctl_handle_int(oidp, &state, 0, req);
 	if (err != 0 || req->newptr == NULL)
@@ -633,7 +646,7 @@ acpi_video_vo_active_sysctl(SYSCTL_HANDL
 	vo_set_device_state(vo->handle,
 	    DSS_COMMIT | (state ? DSS_ACTIVE : DSS_INACTIVE));
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -645,7 +658,7 @@ acpi_video_vo_bright_sysctl(SYSCTL_HANDL
 	int level, preset, err;
 
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->handle == NULL) {
 		err = ENXIO;
 		goto out;
@@ -675,7 +688,7 @@ acpi_video_vo_bright_sysctl(SYSCTL_HANDL
 	vo_set_brightness(vo->handle, (level == -1) ? preset : level);
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -687,7 +700,7 @@ acpi_video_vo_presets_sysctl(SYSCTL_HAND
 
 	err = 0;
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->handle == NULL) {
 		err = ENXIO;
 		goto out;
@@ -718,7 +731,7 @@ acpi_video_vo_presets_sysctl(SYSCTL_HAND
 	*preset = level;
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -730,7 +743,7 @@ acpi_video_vo_levels_sysctl(SYSCTL_HANDL
 	int err;
 
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->vo_levels == NULL) {
 		err = ENODEV;
 		goto out;
@@ -743,7 +756,7 @@ acpi_video_vo_levels_sysctl(SYSCTL_HANDL
 	    vo->vo_numlevels * sizeof(*vo->vo_levels), req);
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -893,6 +906,7 @@ vo_set_brightness(ACPI_HANDLE handle, in
 {
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	status = acpi_SetInteger(handle, "_BCM", level);
 	if (ACPI_FAILURE(status))
 		printf("can't evaluate %s._BCM - %s\n",
@@ -905,6 +919,7 @@ vo_get_device_status(ACPI_HANDLE handle)
 	UINT32 dcs;
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	dcs = 0;
 	status = acpi_GetInteger(handle, "_DCS", &dcs);
 	if (ACPI_FAILURE(status))
@@ -934,6 +949,7 @@ vo_set_device_state(ACPI_HANDLE handle, 
 {
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	status = acpi_SetInteger(handle, "_DSS", state);
 	if (ACPI_FAILURE(status))
 		printf("can't evaluate %s._DSS - %s\n",

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:25:22 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B4E94106568D;
	Thu, 29 Oct 2009 15:25:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A34F78FC14;
	Thu, 29 Oct 2009 15:25:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFPMv8001156;
	Thu, 29 Oct 2009 15:25:22 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFPMgY001154;
	Thu, 29 Oct 2009 15:25:22 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291525.n9TFPMgY001154@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:25:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198601 - in stable/7/sys: . contrib/pf dev/acpica
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:25:22 -0000

Author: jhb
Date: Thu Oct 29 15:25:22 2009
New Revision: 198601
URL: http://svn.freebsd.org/changeset/base/198601

Log:
  MFC 197648:
  Split the 'video' ACPI lock up into two locks to resolve a LOR with the
  sysctl lock.  The 'video' lock now protects the 'bus' of video output
  devices attached to a graphics adapter.  It is used when iterating over
  the list of outputs, etc.  The 'video_output' lock is used to lock the
  output-specific data similar to a driver lock for the individual video
  outputs.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/acpica/acpi_video.c

Modified: stable/7/sys/dev/acpica/acpi_video.c
==============================================================================
--- stable/7/sys/dev/acpica/acpi_video.c	Thu Oct 29 15:24:57 2009	(r198600)
+++ stable/7/sys/dev/acpica/acpi_video.c	Thu Oct 29 15:25:22 2009	(r198601)
@@ -169,7 +169,13 @@ static struct sysctl_oid	*acpi_video_sys
 static struct acpi_video_output_queue crt_units, tv_units,
     ext_units, lcd_units, other_units;
 
+/*
+ * The 'video' lock protects the hierarchy of video output devices
+ * (the video "bus").  The 'video_output' lock protects per-output
+ * data is equivalent to a softc lock for each video output.
+ */
 ACPI_SERIAL_DECL(video, "ACPI video");
+ACPI_SERIAL_DECL(video_output, "ACPI video output");
 MALLOC_DEFINE(M_ACPIVIDEO, "acpivideo", "ACPI video extension");
 
 static int
@@ -235,12 +241,14 @@ acpi_video_attach(device_t dev)
 	acpi_sc = devclass_get_softc(devclass_find("acpi"), 0);
 	if (acpi_sc == NULL)
 		return (ENXIO);
+	ACPI_SERIAL_BEGIN(video);
 	if (acpi_video_sysctl_tree == NULL) {
 		acpi_video_sysctl_tree = SYSCTL_ADD_NODE(&acpi_video_sysctl_ctx,
 				    SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree),
 				    OID_AUTO, "video", CTLFLAG_RD, 0,
 				    "video extension control");
 	}
+	ACPI_SERIAL_END(video);
 
 	sc->device = dev;
 	sc->handle = acpi_get_handle(dev);
@@ -316,6 +324,7 @@ acpi_video_notify_handler(ACPI_HANDLE ha
 		dss_p = 0;
 		lasthand = NULL;
 		ACPI_SERIAL_BEGIN(video);
+		ACPI_SERIAL_BEGIN(video_output);
 		STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) {
 			dss = vo_get_graphics_state(vo->handle);
 			dcs = vo_get_device_status(vo->handle);
@@ -331,6 +340,7 @@ acpi_video_notify_handler(ACPI_HANDLE ha
 		}
 		if (lasthand != NULL)
 			vo_set_device_state(lasthand, dss_p|DSS_COMMIT);
+		ACPI_SERIAL_END(video_output);
 		ACPI_SERIAL_END(video);
 		break;
 	case VID_NOTIFY_REPROBE:
@@ -367,12 +377,14 @@ acpi_video_power_profile(void *context)
 		return;
 
 	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) {
 		if (vo->vo_levels != NULL && vo->vo_brightness == -1)
 			vo_set_brightness(vo->handle,
 			    state == POWER_PROFILE_ECONOMY ?
 			    vo->vo_economy : vo->vo_fullpower);
 	}
+	ACPI_SERIAL_END(video_output);
 	ACPI_SERIAL_END(video);
 }
 
@@ -550,7 +562,7 @@ static void
 acpi_video_vo_bind(struct acpi_video_output *vo, ACPI_HANDLE handle)
 {
 
-	ACPI_SERIAL_ASSERT(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->vo_levels != NULL)
 		AcpiOsFree(vo->vo_levels);
 	vo->handle = handle;
@@ -565,6 +577,7 @@ acpi_video_vo_bind(struct acpi_video_out
 			/* XXX - see above. */
 			vo->vo_economy = vo->vo_levels[BCL_ECONOMY];
 	}
+	ACPI_SERIAL_END(video_output);
 }
 
 static void
@@ -605,7 +618,7 @@ acpi_video_vo_check_level(struct acpi_vi
 {
 	int i;
 
-	ACPI_SERIAL_ASSERT(video);
+	ACPI_SERIAL_ASSERT(video_output);
 	if (vo->vo_levels == NULL)
 		return (ENODEV);
 	for (i = 0; i < vo->vo_numlevels; i++)
@@ -624,7 +637,7 @@ acpi_video_vo_active_sysctl(SYSCTL_HANDL
 	vo = (struct acpi_video_output *)arg1;
 	if (vo->handle == NULL)
 		return (ENXIO);
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	state = (vo_get_device_status(vo->handle) & DCS_ACTIVE) ? 1 : 0;
 	err = sysctl_handle_int(oidp, &state, 0, req);
 	if (err != 0 || req->newptr == NULL)
@@ -632,7 +645,7 @@ acpi_video_vo_active_sysctl(SYSCTL_HANDL
 	vo_set_device_state(vo->handle,
 	    DSS_COMMIT | (state ? DSS_ACTIVE : DSS_INACTIVE));
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -644,7 +657,7 @@ acpi_video_vo_bright_sysctl(SYSCTL_HANDL
 	int level, preset, err;
 
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->handle == NULL) {
 		err = ENXIO;
 		goto out;
@@ -674,7 +687,7 @@ acpi_video_vo_bright_sysctl(SYSCTL_HANDL
 	vo_set_brightness(vo->handle, (level == -1) ? preset : level);
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -686,7 +699,7 @@ acpi_video_vo_presets_sysctl(SYSCTL_HAND
 
 	err = 0;
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->handle == NULL) {
 		err = ENXIO;
 		goto out;
@@ -717,7 +730,7 @@ acpi_video_vo_presets_sysctl(SYSCTL_HAND
 	*preset = level;
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -729,7 +742,7 @@ acpi_video_vo_levels_sysctl(SYSCTL_HANDL
 	int err;
 
 	vo = (struct acpi_video_output *)arg1;
-	ACPI_SERIAL_BEGIN(video);
+	ACPI_SERIAL_BEGIN(video_output);
 	if (vo->vo_levels == NULL) {
 		err = ENODEV;
 		goto out;
@@ -742,7 +755,7 @@ acpi_video_vo_levels_sysctl(SYSCTL_HANDL
 	    vo->vo_numlevels * sizeof(*vo->vo_levels), req);
 
 out:
-	ACPI_SERIAL_END(video);
+	ACPI_SERIAL_END(video_output);
 	return (err);
 }
 
@@ -892,6 +905,7 @@ vo_set_brightness(ACPI_HANDLE handle, in
 {
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	status = acpi_SetInteger(handle, "_BCM", level);
 	if (ACPI_FAILURE(status))
 		printf("can't evaluate %s._BCM - %s\n",
@@ -904,6 +918,7 @@ vo_get_device_status(ACPI_HANDLE handle)
 	UINT32 dcs;
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	dcs = 0;
 	status = acpi_GetInteger(handle, "_DCS", &dcs);
 	if (ACPI_FAILURE(status))
@@ -933,6 +948,7 @@ vo_set_device_state(ACPI_HANDLE handle, 
 {
 	ACPI_STATUS status;
 
+	ACPI_SERIAL_ASSERT(video_output);
 	status = acpi_SetInteger(handle, "_DSS", state);
 	if (ACPI_FAILURE(status))
 		printf("can't evaluate %s._DSS - %s\n",

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:28:05 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B1C021065670;
	Thu, 29 Oct 2009 15:28:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9F2828FC15;
	Thu, 29 Oct 2009 15:28:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFS5ar001264;
	Thu, 29 Oct 2009 15:28:05 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFS5et001262;
	Thu, 29 Oct 2009 15:28:05 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291528.n9TFS5et001262@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:28:05 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198602 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/acpica dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:28:05 -0000

Author: jhb
Date: Thu Oct 29 15:28:05 2009
New Revision: 198602
URL: http://svn.freebsd.org/changeset/base/198602

Log:
  MFC 197649:
  Do not hold the ACPI A/C adapter lock when changing the power profile.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/acpica/acpi_acad.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/acpica/acpi_acad.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_acad.c	Thu Oct 29 15:25:22 2009	(r198601)
+++ stable/8/sys/dev/acpica/acpi_acad.c	Thu Oct 29 15:28:05 2009	(r198602)
@@ -109,13 +109,14 @@ acpi_acad_get_status(void *context)
     ACPI_SERIAL_BEGIN(acad);
     if (newstatus != -1 && sc->status != newstatus) {
 	sc->status = newstatus;
+	ACPI_SERIAL_END(acad);
 	power_profile_set_state(newstatus ? POWER_PROFILE_PERFORMANCE :
 	    POWER_PROFILE_ECONOMY);
 	ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
 	    "%s Line\n", newstatus ? "On" : "Off");
 	acpi_UserNotify("ACAD", h, newstatus);
-    }
-    ACPI_SERIAL_END(acad);
+    } else
+	ACPI_SERIAL_END(acad);
 }
 
 static void

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:28:31 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1E52E1065679;
	Thu, 29 Oct 2009 15:28:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D30E8FC22;
	Thu, 29 Oct 2009 15:28:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFSUWc001309;
	Thu, 29 Oct 2009 15:28:30 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFSURl001307;
	Thu, 29 Oct 2009 15:28:30 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291528.n9TFSURl001307@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:28:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198603 - in stable/7/sys: . contrib/pf dev/acpica
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:28:31 -0000

Author: jhb
Date: Thu Oct 29 15:28:30 2009
New Revision: 198603
URL: http://svn.freebsd.org/changeset/base/198603

Log:
  MFC 197649:
  Do not hold the ACPI A/C adapter lock when changing the power profile.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/acpica/acpi_acad.c

Modified: stable/7/sys/dev/acpica/acpi_acad.c
==============================================================================
--- stable/7/sys/dev/acpica/acpi_acad.c	Thu Oct 29 15:28:05 2009	(r198602)
+++ stable/7/sys/dev/acpica/acpi_acad.c	Thu Oct 29 15:28:30 2009	(r198603)
@@ -108,13 +108,14 @@ acpi_acad_get_status(void *context)
     ACPI_SERIAL_BEGIN(acad);
     if (newstatus != -1 && sc->status != newstatus) {
 	sc->status = newstatus;
+	ACPI_SERIAL_END(acad);
 	power_profile_set_state(newstatus ? POWER_PROFILE_PERFORMANCE :
 	    POWER_PROFILE_ECONOMY);
 	ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
 	    "%s Line\n", newstatus ? "On" : "Off");
 	acpi_UserNotify("ACAD", h, newstatus);
-    }
-    ACPI_SERIAL_END(acad);
+    } else
+	ACPI_SERIAL_END(acad);
 }
 
 static void

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:39:19 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 27E3F1065676;
	Thu, 29 Oct 2009 15:39:19 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1602C8FC21;
	Thu, 29 Oct 2009 15:39:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFdIq5001588;
	Thu, 29 Oct 2009 15:39:18 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFdICB001586;
	Thu, 29 Oct 2009 15:39:18 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291539.n9TFdICB001586@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:39:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198604 - stable/8/share/man/man9
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:39:19 -0000

Author: jhb
Date: Thu Oct 29 15:39:18 2009
New Revision: 198604
URL: http://svn.freebsd.org/changeset/base/198604

Log:
  MFC 198085:
  Add a manual page for BUS_BIND_INTR() and bus_bind_intr().

Added:
  stable/8/share/man/man9/BUS_BIND_INTR.9
     - copied unchanged from r198085, head/share/man/man9/BUS_BIND_INTR.9
Modified:
  stable/8/share/man/man9/   (props changed)
  stable/8/share/man/man9/Makefile

Copied: stable/8/share/man/man9/BUS_BIND_INTR.9 (from r198085, head/share/man/man9/BUS_BIND_INTR.9)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/share/man/man9/BUS_BIND_INTR.9	Thu Oct 29 15:39:18 2009	(r198604, copy of r198085, head/share/man/man9/BUS_BIND_INTR.9)
@@ -0,0 +1,96 @@
+.\" -*- nroff -*-
+.\"
+.\" Copyright (c) 2009 Advanced Computing Technologies LLC
+.\" Written by: John H. Baldwin 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd October 14, 2009
+.Dt BUS_BIND_INTR 9
+.Os
+.Sh NAME
+.Nm BUS_BIND_INTR ,
+.Nm bus_bind_intr
+.Nd "bind an interrupt resource to a specific CPU"
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/bus.h
+.Ft int
+.Fo BUS_BIND_INTR
+.Fa "device_t dev" "device_t child" "struct resource *irq" "int cpu"
+.Fc
+.Ft int
+.Fn bus_bind_intr "device_t dev" "struct resource *irq" "int cpu"
+.Sh DESCRIPTION
+The
+.Fn BUS_BIND_INTR
+method allows an interrupt resource to be pinned to a specific CPU.
+The interrupt resource must have an interrupt handler attached via
+.Xr BUS_SETUP_INTR 9 .
+The
+.Fa cpu
+parameter corresponds to the ID of a valid CPU in the system.
+Binding an interrupt restricts the
+.Xr cpuset 2
+of any associated interrupt threads to only include the specified CPU.
+It may also direct the low-level interrupt handling of the interrupt to the
+specified CPU as well,
+but this behavior is platform-dependent.
+If the value
+.Dv NOCPU
+is used for
+.Fa cpu ,
+then the interrupt will be
+.Dq unbound
+which restores any associated interrupt threads back to the default cpuset.
+.Pp
+Non-sleepable locks such as mutexes should not be held across calls to these
+functions.
+.Pp
+The
+.Fn bus_bind_intr
+function is a simple wrapper around
+.Fn BUS_BIND_INTR .
+.Pp
+Note that currently there is no attempt made to arbitrate between
+multiple bind requests for the same interrupt from either the same
+device or multiple devices.
+There is also no arbitration between interrupt binding requests submitted
+by userland via
+.Xr cpuset 2
+and
+.Fn BUS_BIND_INTR .
+The most recent binding request is the one that will be in effect.
+.Sh SEE ALSO
+.Xr BUS_SETUP_INTR 9 ,
+.Xr cpuset 2 ,
+.Xr device 9
+.Sh HISTORY
+The
+.Fn BUS_BIND_INTR
+method and
+.Fn bus_bind_intr
+functions first appeared in
+.Fx 7.2 .

Modified: stable/8/share/man/man9/Makefile
==============================================================================
--- stable/8/share/man/man9/Makefile	Thu Oct 29 15:28:30 2009	(r198603)
+++ stable/8/share/man/man9/Makefile	Thu Oct 29 15:39:18 2009	(r198604)
@@ -23,6 +23,7 @@ MAN=	accept_filter.9 \
 	bus_activate_resource.9 \
 	BUS_ADD_CHILD.9 \
 	bus_alloc_resource.9 \
+	BUS_BIND_INTR.9 \
 	bus_child_present.9 \
 	BUS_CONFIG_INTR.9 \
 	bus_dma.9 \
@@ -402,6 +403,7 @@ MLINKS+=bpf.9 bpf_filter.9 \
 MLINKS+=buf.9 bp.9
 MLINKS+=bus_activate_resource.9 bus_deactivate_resource.9
 MLINKS+=bus_alloc_resource.9 bus_alloc_resource_any.9
+MLINKS+=BUS_BIND_INTR.9 bus_bind_intr.9
 MLINKS+=bus_dma.9 busdma.9 \
 	bus_dma.9 bus_dmamap_create.9 \
 	bus_dma.9 bus_dmamap_destroy.9 \

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 15:39:30 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 70ED9106566C;
	Thu, 29 Oct 2009 15:39:30 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5F4318FC14;
	Thu, 29 Oct 2009 15:39:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TFdUMC001628;
	Thu, 29 Oct 2009 15:39:30 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TFdUBS001626;
	Thu, 29 Oct 2009 15:39:30 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291539.n9TFdUBS001626@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 15:39:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198605 - stable/7/share/man/man9
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 15:39:30 -0000

Author: jhb
Date: Thu Oct 29 15:39:30 2009
New Revision: 198605
URL: http://svn.freebsd.org/changeset/base/198605

Log:
  MFC 198085:
  Add a manual page for BUS_BIND_INTR() and bus_bind_intr().

Added:
  stable/7/share/man/man9/BUS_BIND_INTR.9
     - copied unchanged from r198085, head/share/man/man9/BUS_BIND_INTR.9
Modified:
  stable/7/share/man/man9/   (props changed)
  stable/7/share/man/man9/Makefile

Copied: stable/7/share/man/man9/BUS_BIND_INTR.9 (from r198085, head/share/man/man9/BUS_BIND_INTR.9)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/7/share/man/man9/BUS_BIND_INTR.9	Thu Oct 29 15:39:30 2009	(r198605, copy of r198085, head/share/man/man9/BUS_BIND_INTR.9)
@@ -0,0 +1,96 @@
+.\" -*- nroff -*-
+.\"
+.\" Copyright (c) 2009 Advanced Computing Technologies LLC
+.\" Written by: John H. Baldwin 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd October 14, 2009
+.Dt BUS_BIND_INTR 9
+.Os
+.Sh NAME
+.Nm BUS_BIND_INTR ,
+.Nm bus_bind_intr
+.Nd "bind an interrupt resource to a specific CPU"
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/bus.h
+.Ft int
+.Fo BUS_BIND_INTR
+.Fa "device_t dev" "device_t child" "struct resource *irq" "int cpu"
+.Fc
+.Ft int
+.Fn bus_bind_intr "device_t dev" "struct resource *irq" "int cpu"
+.Sh DESCRIPTION
+The
+.Fn BUS_BIND_INTR
+method allows an interrupt resource to be pinned to a specific CPU.
+The interrupt resource must have an interrupt handler attached via
+.Xr BUS_SETUP_INTR 9 .
+The
+.Fa cpu
+parameter corresponds to the ID of a valid CPU in the system.
+Binding an interrupt restricts the
+.Xr cpuset 2
+of any associated interrupt threads to only include the specified CPU.
+It may also direct the low-level interrupt handling of the interrupt to the
+specified CPU as well,
+but this behavior is platform-dependent.
+If the value
+.Dv NOCPU
+is used for
+.Fa cpu ,
+then the interrupt will be
+.Dq unbound
+which restores any associated interrupt threads back to the default cpuset.
+.Pp
+Non-sleepable locks such as mutexes should not be held across calls to these
+functions.
+.Pp
+The
+.Fn bus_bind_intr
+function is a simple wrapper around
+.Fn BUS_BIND_INTR .
+.Pp
+Note that currently there is no attempt made to arbitrate between
+multiple bind requests for the same interrupt from either the same
+device or multiple devices.
+There is also no arbitration between interrupt binding requests submitted
+by userland via
+.Xr cpuset 2
+and
+.Fn BUS_BIND_INTR .
+The most recent binding request is the one that will be in effect.
+.Sh SEE ALSO
+.Xr BUS_SETUP_INTR 9 ,
+.Xr cpuset 2 ,
+.Xr device 9
+.Sh HISTORY
+The
+.Fn BUS_BIND_INTR
+method and
+.Fn bus_bind_intr
+functions first appeared in
+.Fx 7.2 .

Modified: stable/7/share/man/man9/Makefile
==============================================================================
--- stable/7/share/man/man9/Makefile	Thu Oct 29 15:39:18 2009	(r198604)
+++ stable/7/share/man/man9/Makefile	Thu Oct 29 15:39:30 2009	(r198605)
@@ -21,6 +21,7 @@ MAN=	accept_filter.9 \
 	bus_activate_resource.9 \
 	BUS_ADD_CHILD.9 \
 	bus_alloc_resource.9 \
+	BUS_BIND_INTR.9 \
 	bus_child_present.9 \
 	BUS_CONFIG_INTR.9 \
 	bus_dma.9 \
@@ -377,6 +378,7 @@ MLINKS+=atomic.9 atomic_add.9 \
 MLINKS+=buf.9 bp.9
 MLINKS+=bus_activate_resource.9 bus_deactivate_resource.9
 MLINKS+=bus_alloc_resource.9 bus_alloc_resource_any.9
+MLINKS+=BUS_BIND_INTR.9 bus_bind_intr.9
 MLINKS+=bus_dma.9 busdma.9 \
 	bus_dma.9 bus_dmamap_create.9 \
 	bus_dma.9 bus_dmamap_destroy.9 \

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:00:28 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4F90010656A4;
	Thu, 29 Oct 2009 16:00:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 397C08FC1A;
	Thu, 29 Oct 2009 16:00:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TG0SMB002406;
	Thu, 29 Oct 2009 16:00:28 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TG0Smj002397;
	Thu, 29 Oct 2009 16:00:28 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291600.n9TG0Smj002397@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 16:00:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198610 - in stable/8/sys: . amd64/acpica amd64/include
	amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica
	contrib/pf dev/acpica dev/xen/xenpci i386/acpica i386/include
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:00:28 -0000

Author: jhb
Date: Thu Oct 29 16:00:27 2009
New Revision: 198610
URL: http://svn.freebsd.org/changeset/base/198610

Log:
  MFC 197439:
  Extract the code to find and map the MADT ACPI table during early kernel
  startup and genericize it so it can be reused to map other tables as well:
  - Add a routine to walk a list of ACPI subtables such as those used in the
    APIC and SRAT tables in the MI acpi(4) driver.
  - Move the routines for mapping and unmapping an ACPI table as well as
    mapping the RSDT or XSDT and searching for a table with a given signature
    out into acpica_machdep.c for both amd64 and i386.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/acpica/acpi_machdep.c
  stable/8/sys/amd64/acpica/madt.c
  stable/8/sys/amd64/include/acpica_machdep.h
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/acpica/acpi.c
  stable/8/sys/dev/acpica/acpivar.h
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/i386/acpica/acpi_machdep.c
  stable/8/sys/i386/acpica/madt.c
  stable/8/sys/i386/include/acpica_machdep.h

Modified: stable/8/sys/amd64/acpica/acpi_machdep.c
==============================================================================
--- stable/8/sys/amd64/acpica/acpi_machdep.c	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/amd64/acpica/acpi_machdep.c	Thu Oct 29 16:00:27 2009	(r198610)
@@ -32,8 +32,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -100,6 +104,246 @@ acpi_cpu_c1()
 }
 
 /*
+ * Support for mapping ACPI tables during early boot.  Currently this
+ * uses the crashdump map to map each table.  However, the crashdump
+ * map is created in pmap_bootstrap() right after the direct map, so
+ * we should be able to just use pmap_mapbios() here instead.
+ *
+ * This makes the following assumptions about how we use this KVA:
+ * pages 0 and 1 are used to map in the header of each table found via
+ * the RSDT or XSDT and pages 2 to n are used to map in the RSDT or
+ * XSDT.  This has to use 2 pages for the table headers in case a
+ * header spans a page boundary.
+ *
+ * XXX: We don't ensure the table fits in the available address space
+ * in the crashdump map.
+ */
+
+/*
+ * Map some memory using the crashdump map.  'offset' is an offset in
+ * pages into the crashdump map to use for the start of the mapping.
+ */
+static void *
+table_map(vm_paddr_t pa, int offset, vm_offset_t length)
+{
+	vm_offset_t va, off;
+	void *data;
+
+	off = pa & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	pa = pa & PG_FRAME;
+	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
+	    (offset * PAGE_SIZE);
+	data = (void *)(va + off);
+	length -= PAGE_SIZE;
+	while (length > 0) {
+		va += PAGE_SIZE;
+		pa += PAGE_SIZE;
+		length -= PAGE_SIZE;
+		pmap_kenter(va, pa);
+		invlpg(va);
+	}
+	return (data);
+}
+
+/* Unmap memory previously mapped with table_map(). */
+static void
+table_unmap(void *data, vm_offset_t length)
+{
+	vm_offset_t va, off;
+
+	va = (vm_offset_t)data;
+	off = va & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	va &= ~PAGE_MASK;
+	while (length > 0) {
+		pmap_kremove(va);
+		invlpg(va);
+		va += PAGE_SIZE;
+		length -= PAGE_SIZE;
+	}
+}
+
+/*
+ * Map a table at a given offset into the crashdump map.  It first
+ * maps the header to determine the table length and then maps the
+ * entire table.
+ */
+static void *
+map_table(vm_paddr_t pa, int offset, const char *sig)
+{
+	ACPI_TABLE_HEADER *header;
+	vm_offset_t length;
+	void *table;
+
+	header = table_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
+	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+		return (NULL);
+	}
+	length = header->Length;
+	table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+	table = table_map(pa, offset, length);
+	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
+		if (bootverbose)
+			printf("ACPI: Failed checksum for table %s\n", sig);
+		table_unmap(table, length);
+		return (NULL);
+	}
+	return (table);
+}
+
+/*
+ * See if a given ACPI table is the requested table.  Returns the
+ * length of the able if it matches or zero on failure.
+ */
+static int
+probe_table(vm_paddr_t address, const char *sig)
+{
+	ACPI_TABLE_HEADER *table;
+
+	table = table_map(address, 0, sizeof(ACPI_TABLE_HEADER));
+	if (table == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map table at 0x%jx\n",
+			    (uintmax_t)address);
+		return (0);
+	}
+	if (bootverbose)
+		printf("Table '%.4s' at 0x%jx\n", table->Signature,
+		    (uintmax_t)address);
+
+	if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+		return (0);
+	}
+	table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+	return (1);
+}
+
+/*
+ * Try to map a table at a given physical address previously returned
+ * by acpi_find_table().
+ */
+void *
+acpi_map_table(vm_paddr_t pa, const char *sig)
+{
+
+	return (map_table(pa, 0, sig));
+}
+
+/* Unmap a table previously mapped via acpi_map_table(). */
+void
+acpi_unmap_table(void *table)
+{
+	ACPI_TABLE_HEADER *header;
+
+	header = (ACPI_TABLE_HEADER *)table;
+	table_unmap(table, header->Length);
+}
+
+/*
+ * Return the physical address of the requested table or zero if one
+ * is not found.
+ */
+vm_paddr_t
+acpi_find_table(const char *sig)
+{
+	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *table;
+	vm_paddr_t addr;
+	int i, count;
+
+	if (resource_disabled("acpi", 0))
+		return (0);
+
+	/*
+	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
+	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
+	 * pmap_mapbios() to map the RSDP.
+	 */
+	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+		return (0);
+	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
+	if (rsdp == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map RSDP\n");
+		return (0);
+	}
+
+	/*
+	 * For ACPI >= 2.0, use the XSDT if it is available.
+	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 2
+	 * in the crashdump area.  Pages 0 and 1 are used to map in the
+	 * headers of candidate ACPI tables.
+	 */
+	addr = 0;
+	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
+		/*
+		 * AcpiOsGetRootPointer only verifies the checksum for
+		 * the version 1.0 portion of the RSDP.  Version 2.0 has
+		 * an additional checksum that we verify first.
+		 */
+		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
+			if (bootverbose)
+				printf("ACPI: RSDP failed extended checksum\n");
+			return (0);
+		}
+		xsdt = map_table(rsdp->XsdtPhysicalAddress, 2, ACPI_SIG_XSDT);
+		if (xsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map XSDT\n");
+			return (0);
+		}
+		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT64);
+		for (i = 0; i < count; i++)
+			if (probe_table(xsdt->TableOffsetEntry[i], sig)) {
+				addr = xsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(xsdt);
+	} else {
+		rsdt = map_table(rsdp->RsdtPhysicalAddress, 2, ACPI_SIG_RSDT);
+		if (rsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map RSDT\n");
+			return (0);
+		}
+		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT32);
+		for (i = 0; i < count; i++)
+			if (probe_table(rsdt->TableOffsetEntry[i], sig)) {
+				addr = rsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(rsdt);
+	}
+	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
+	if (addr == 0) {
+		if (bootverbose)
+			printf("ACPI: No %s table found\n", sig);
+		return (0);
+	}
+	if (bootverbose)
+		printf("%s: Found table at 0x%jx\n", sig, (uintmax_t)addr);
+
+	/*
+	 * Verify that we can map the full table and that its checksum is
+	 * correct, etc.
+	 */
+	table = map_table(addr, 0, sig);
+	if (table == NULL)
+		return (0);
+	acpi_unmap_table(table);
+
+	return (addr);
+}
+
+/*
  * ACPI nexus(4) driver.
  */
 static int

Modified: stable/8/sys/amd64/acpica/madt.c
==============================================================================
--- stable/8/sys/amd64/acpica/madt.c	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/amd64/acpica/madt.c	Thu Oct 29 16:00:27 2009	(r198610)
@@ -36,27 +36,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
-#include 
 #include 
 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
-#include 
 #include 
 
 #include 
 #include 
 
-typedef	void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
-
 /* These two arrays are indexed by APIC IDs. */
 struct ioapic_info {
 	void *io_apic;
@@ -79,8 +71,6 @@ static enum intr_polarity interrupt_pola
 static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
 static int	madt_find_cpu(u_int acpi_id, u_int *apic_id);
 static int	madt_find_interrupt(int intr, void **apic, u_int *pin);
-static void	*madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
-static void	*madt_map_table(vm_paddr_t pa, int offset, const char *sig);
 static void	madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
 static void	madt_parse_interrupt_override(
 		    ACPI_MADT_INTERRUPT_OVERRIDE *intr);
@@ -92,13 +82,10 @@ static int	madt_probe(void);
 static int	madt_probe_cpus(void);
 static void	madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
 		    void *arg __unused);
-static int	madt_probe_table(vm_paddr_t address);
 static void	madt_register(void *dummy);
 static int	madt_setup_local(void);
 static int	madt_setup_io(void);
-static void	madt_unmap(void *data, vm_offset_t length);
-static void	madt_unmap_table(void *table);
-static void	madt_walk_table(madt_entry_handler *handler, void *arg);
+static void	madt_walk_table(acpi_subtable_handler *handler, void *arg);
 
 static struct apic_enumerator madt_enumerator = {
 	"MADT",
@@ -109,224 +96,30 @@ static struct apic_enumerator madt_enume
 };
 
 /*
- * Code to abuse the crashdump map to map in the tables for the early
- * probe.  We cheat and make the following assumptions about how we
- * use this KVA: pages 0 and 1 are used to map in the header of each
- * table found via the RSDT or XSDT and pages 2 to n are used to map
- * in the RSDT or XSDT.  We have to use 2 pages for the table headers
- * in case a header spans a page boundary.  The offset is in pages;
- * the length is in bytes.
- */
-static void *
-madt_map(vm_paddr_t pa, int offset, vm_offset_t length)
-{
-	vm_offset_t va, off;
-	void *data;
-
-	off = pa & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	pa = pa & PG_FRAME;
-	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
-	    (offset * PAGE_SIZE);
-	data = (void *)(va + off);
-	length -= PAGE_SIZE;
-	while (length > 0) {
-		va += PAGE_SIZE;
-		pa += PAGE_SIZE;
-		length -= PAGE_SIZE;
-		pmap_kenter(va, pa);
-		invlpg(va);
-	}
-	return (data);
-}
-
-static void
-madt_unmap(void *data, vm_offset_t length)
-{
-	vm_offset_t va, off;
-
-	va = (vm_offset_t)data;
-	off = va & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	va &= ~PAGE_MASK;
-	while (length > 0) {
-		pmap_kremove(va);
-		invlpg(va);
-		va += PAGE_SIZE;
-		length -= PAGE_SIZE;
-	}
-}
-
-static void *
-madt_map_table(vm_paddr_t pa, int offset, const char *sig)
-{
-	ACPI_TABLE_HEADER *header;
-	vm_offset_t length;
-	void *table;
-
-	header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
-	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
-		madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-		return (NULL);
-	}
-	length = header->Length;
-	madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-	table = madt_map(pa, offset, length);
-	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
-		if (bootverbose)
-			printf("MADT: Failed checksum for table %s\n", sig);
-		madt_unmap(table, length);
-		return (NULL);
-	}
-	return (table);
-}
-
-static void
-madt_unmap_table(void *table)
-{
-	ACPI_TABLE_HEADER *header;
-
-	header = (ACPI_TABLE_HEADER *)table;
-	madt_unmap(table, header->Length);
-}
-
-/*
  * Look for an ACPI Multiple APIC Description Table ("APIC")
  */
 static int
 madt_probe(void)
 {
-	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
-	ACPI_TABLE_RSDP *rsdp;
-	ACPI_TABLE_RSDT *rsdt;
-	ACPI_TABLE_XSDT *xsdt;
-	int i, count;
-
-	if (resource_disabled("acpi", 0))
-		return (ENXIO);
 
-	/*
-	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
-	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
-	 * pmap_mapbios() to map the RSDP.
-	 */
-	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
-		return (ENXIO);
-	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
-	if (rsdp == NULL) {
-		if (bootverbose)
-			printf("MADT: Failed to map RSDP\n");
+	madt_physaddr = acpi_find_table(ACPI_SIG_MADT);
+	if (madt_physaddr == 0)
 		return (ENXIO);
-	}
-
-	/*
-	 * For ACPI >= 2.0, use the XSDT if it is available.
-	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 1
-	 * in the crashdump area.  Page 0 is used to map in the
-	 * headers of candidate ACPI tables.
-	 */
-	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
-		/*
-		 * AcpiOsGetRootPointer only verifies the checksum for
-		 * the version 1.0 portion of the RSDP.  Version 2.0 has
-		 * an additional checksum that we verify first.
-		 */
-		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
-			if (bootverbose)
-				printf("MADT: RSDP failed extended checksum\n");
-			return (ENXIO);
-		}
-		xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 2,
-		    ACPI_SIG_XSDT);
-		if (xsdt == NULL) {
-			if (bootverbose)
-				printf("MADT: Failed to map XSDT\n");
-			return (ENXIO);
-		}
-		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
-		    sizeof(UINT64);
-		for (i = 0; i < count; i++)
-			if (madt_probe_table(xsdt->TableOffsetEntry[i]))
-				break;
-		madt_unmap_table(xsdt);
-	} else {
-		rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 2,
-		    ACPI_SIG_RSDT);
-		if (rsdt == NULL) {
-			if (bootverbose)
-				printf("MADT: Failed to map RSDT\n");
-			return (ENXIO);
-		}
-		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
-		    sizeof(UINT32);
-		for (i = 0; i < count; i++)
-			if (madt_probe_table(rsdt->TableOffsetEntry[i]))
-				break;
-		madt_unmap_table(rsdt);
-	}
-	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
-	if (madt_physaddr == 0) {
-		if (bootverbose)
-			printf("MADT: No MADT table found\n");
-		return (ENXIO);
-	}
-	if (bootverbose)
-		printf("MADT: Found table at 0x%jx\n",
-		    (uintmax_t)madt_physaddr);
-
-	/*
-	 * Verify that we can map the full table and that its checksum is
-	 * correct, etc.
-	 */
-	madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
-	if (madt == NULL)
-		return (ENXIO);
-	madt_unmap_table(madt);
-	madt = NULL;
-
 	return (0);
 }
 
 /*
- * See if a given ACPI table is the MADT.
- */
-static int
-madt_probe_table(vm_paddr_t address)
-{
-	ACPI_TABLE_HEADER *table;
-
-	table = madt_map(address, 0, sizeof(ACPI_TABLE_HEADER));
-	if (table == NULL) {
-		if (bootverbose)
-			printf("MADT: Failed to map table at 0x%jx\n",
-			    (uintmax_t)address);
-		return (0);
-	}
-	if (bootverbose)
-		printf("Table '%.4s' at 0x%jx\n", table->Signature,
-		    (uintmax_t)address);
-
-	if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) {
-		madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
-		return (0);
-	}
-	madt_physaddr = address;
-	madt_length = table->Length;
-	madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
-	return (1);
-}
-
-/*
  * Run through the MP table enumerating CPUs.
  */
 static int
 madt_probe_cpus(void)
 {
 
-	madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
+	madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT);
+	madt_length = madt->Header.Length;
 	KASSERT(madt != NULL, ("Unable to re-map MADT"));
 	madt_walk_table(madt_probe_cpus_handler, NULL);
-	madt_unmap_table(madt);
+	acpi_unmap_table(madt);
 	madt = NULL;
 	return (0);
 }
@@ -417,17 +210,11 @@ SYSINIT(madt_register, SI_SUB_TUNABLES -
  * Call the handler routine for each entry in the MADT table.
  */
 static void
-madt_walk_table(madt_entry_handler *handler, void *arg)
+madt_walk_table(acpi_subtable_handler *handler, void *arg)
 {
-	ACPI_SUBTABLE_HEADER *entry;
-	u_char *p, *end;
 
-	end = (u_char *)(madt) + madt->Header.Length;
-	for (p = (u_char *)(madt + 1); p < end; ) {
-		entry = (ACPI_SUBTABLE_HEADER *)p;
-		handler(entry, arg);
-		p += entry->Length;
-	}
+	acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
+	    handler, arg);
 }
 
 static void

Modified: stable/8/sys/amd64/include/acpica_machdep.h
==============================================================================
--- stable/8/sys/amd64/include/acpica_machdep.h	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/amd64/include/acpica_machdep.h	Thu Oct 29 16:00:27 2009	(r198610)
@@ -77,5 +77,8 @@ extern int	acpi_release_global_lock(uint
 
 void	acpi_SetDefaultIntrModel(int model);
 void	acpi_cpu_c1(void);
+void	*acpi_map_table(vm_paddr_t pa, const char *sig);
+void	acpi_unmap_table(void *table);
+vm_paddr_t acpi_find_table(const char *sig);
 
 #endif /* __ACPICA_MACHDEP_H__ */

Modified: stable/8/sys/dev/acpica/acpi.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi.c	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/dev/acpica/acpi.c	Thu Oct 29 16:00:27 2009	(r198610)
@@ -2290,6 +2290,28 @@ acpi_SetIntrModel(int model)
 }
 
 /*
+ * Walk subtables of a table and call a callback routine for each
+ * subtable.  The caller should provide the first subtable and a
+ * pointer to the end of the table.  This can be used to walk tables
+ * such as MADT and SRAT that use subtable entries.
+ */
+void
+acpi_walk_subtables(void *first, void *end, acpi_subtable_handler *handler,
+    void *arg)
+{
+    ACPI_SUBTABLE_HEADER *entry;
+
+    for (entry = first; (void *)entry < end; ) {
+	/* Avoid an infinite loop if we hit a bogus entry. */
+	if (entry->Length < sizeof(ACPI_SUBTABLE_HEADER))
+	    return;
+
+	handler(entry, arg);
+	entry = ACPI_ADD_PTR(ACPI_SUBTABLE_HEADER, entry, entry->Length);
+    }
+}
+
+/*
  * DEPRECATED.  This interface has serious deficiencies and will be
  * removed.
  *

Modified: stable/8/sys/dev/acpica/acpivar.h
==============================================================================
--- stable/8/sys/dev/acpica/acpivar.h	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/dev/acpica/acpivar.h	Thu Oct 29 16:00:27 2009	(r198610)
@@ -307,6 +307,9 @@ void		acpi_EnterDebugger(void);
 	ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL | \
 	    ACPI_STA_BATT_PRESENT)
 
+/* Callback function type for walking subtables within a table. */
+typedef void acpi_subtable_handler(ACPI_SUBTABLE_HEADER *, void *);
+
 BOOLEAN		acpi_DeviceIsPresent(device_t dev);
 BOOLEAN		acpi_BatteryIsPresent(device_t dev);
 ACPI_STATUS	acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
@@ -340,6 +343,8 @@ void		acpi_UserNotify(const char *subsys
 int		acpi_bus_alloc_gas(device_t dev, int *type, int *rid,
 		    ACPI_GENERIC_ADDRESS *gas, struct resource **res,
 		    u_int flags);
+void		acpi_walk_subtables(void *first, void *end,
+		    acpi_subtable_handler *handler, void *arg);
 
 struct acpi_parse_resource_set {
     void	(*set_init)(device_t dev, void *arg, void **context);

Modified: stable/8/sys/i386/acpica/acpi_machdep.c
==============================================================================
--- stable/8/sys/i386/acpica/acpi_machdep.c	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/i386/acpica/acpi_machdep.c	Thu Oct 29 16:00:27 2009	(r198610)
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -555,6 +557,244 @@ acpi_cpu_c1()
 }
 
 /*
+ * Support for mapping ACPI tables during early boot.  This abuses the
+ * crashdump map because the kernel cannot allocate KVA in
+ * pmap_mapbios() when this is used.  This makes the following
+ * assumptions about how we use this KVA: pages 0 and 1 are used to
+ * map in the header of each table found via the RSDT or XSDT and
+ * pages 2 to n are used to map in the RSDT or XSDT.  This has to use
+ * 2 pages for the table headers in case a header spans a page
+ * boundary.
+ *
+ * XXX: We don't ensure the table fits in the available address space
+ * in the crashdump map.
+ */
+
+/*
+ * Map some memory using the crashdump map.  'offset' is an offset in
+ * pages into the crashdump map to use for the start of the mapping.
+ */
+static void *
+table_map(vm_paddr_t pa, int offset, vm_offset_t length)
+{
+	vm_offset_t va, off;
+	void *data;
+
+	off = pa & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	pa = pa & PG_FRAME;
+	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
+	    (offset * PAGE_SIZE);
+	data = (void *)(va + off);
+	length -= PAGE_SIZE;
+	while (length > 0) {
+		va += PAGE_SIZE;
+		pa += PAGE_SIZE;
+		length -= PAGE_SIZE;
+		pmap_kenter(va, pa);
+		invlpg(va);
+	}
+	return (data);
+}
+
+/* Unmap memory previously mapped with table_map(). */
+static void
+table_unmap(void *data, vm_offset_t length)
+{
+	vm_offset_t va, off;
+
+	va = (vm_offset_t)data;
+	off = va & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	va &= ~PAGE_MASK;
+	while (length > 0) {
+		pmap_kremove(va);
+		invlpg(va);
+		va += PAGE_SIZE;
+		length -= PAGE_SIZE;
+	}
+}
+
+/*
+ * Map a table at a given offset into the crashdump map.  It first
+ * maps the header to determine the table length and then maps the
+ * entire table.
+ */
+static void *
+map_table(vm_paddr_t pa, int offset, const char *sig)
+{
+	ACPI_TABLE_HEADER *header;
+	vm_offset_t length;
+	void *table;
+
+	header = table_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
+	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+		return (NULL);
+	}
+	length = header->Length;
+	table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+	table = table_map(pa, offset, length);
+	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
+		if (bootverbose)
+			printf("ACPI: Failed checksum for table %s\n", sig);
+		table_unmap(table, length);
+		return (NULL);
+	}
+	return (table);
+}
+
+/*
+ * See if a given ACPI table is the requested table.  Returns the
+ * length of the able if it matches or zero on failure.
+ */
+static int
+probe_table(vm_paddr_t address, const char *sig)
+{
+	ACPI_TABLE_HEADER *table;
+
+	table = table_map(address, 0, sizeof(ACPI_TABLE_HEADER));
+	if (table == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map table at 0x%jx\n",
+			    (uintmax_t)address);
+		return (0);
+	}
+	if (bootverbose)
+		printf("Table '%.4s' at 0x%jx\n", table->Signature,
+		    (uintmax_t)address);
+
+	if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+		return (0);
+	}
+	table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+	return (1);
+}
+
+/*
+ * Try to map a table at a given physical address previously returned
+ * by acpi_find_table().
+ */
+void *
+acpi_map_table(vm_paddr_t pa, const char *sig)
+{
+
+	return (map_table(pa, 0, sig));
+}
+
+/* Unmap a table previously mapped via acpi_map_table(). */
+void
+acpi_unmap_table(void *table)
+{
+	ACPI_TABLE_HEADER *header;
+
+	header = (ACPI_TABLE_HEADER *)table;
+	table_unmap(table, header->Length);
+}
+
+/*
+ * Return the physical address of the requested table or zero if one
+ * is not found.
+ */
+vm_paddr_t
+acpi_find_table(const char *sig)
+{
+	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *table;
+	vm_paddr_t addr;
+	int i, count;
+
+	if (resource_disabled("acpi", 0))
+		return (0);
+
+	/*
+	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
+	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
+	 * pmap_mapbios() to map the RSDP.
+	 */
+	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+		return (0);
+	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
+	if (rsdp == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map RSDP\n");
+		return (0);
+	}
+
+	/*
+	 * For ACPI >= 2.0, use the XSDT if it is available.
+	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 2
+	 * in the crashdump area.  Pages 0 and 1 are used to map in the
+	 * headers of candidate ACPI tables.
+	 */
+	addr = 0;
+	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
+		/*
+		 * AcpiOsGetRootPointer only verifies the checksum for
+		 * the version 1.0 portion of the RSDP.  Version 2.0 has
+		 * an additional checksum that we verify first.
+		 */
+		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
+			if (bootverbose)
+				printf("ACPI: RSDP failed extended checksum\n");
+			return (0);
+		}
+		xsdt = map_table(rsdp->XsdtPhysicalAddress, 2, ACPI_SIG_XSDT);
+		if (xsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map XSDT\n");
+			return (0);
+		}
+		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT64);
+		for (i = 0; i < count; i++)
+			if (probe_table(xsdt->TableOffsetEntry[i], sig)) {
+				addr = xsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(xsdt);
+	} else {
+		rsdt = map_table(rsdp->RsdtPhysicalAddress, 2, ACPI_SIG_RSDT);
+		if (rsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map RSDT\n");
+			return (0);
+		}
+		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT32);
+		for (i = 0; i < count; i++)
+			if (probe_table(rsdt->TableOffsetEntry[i], sig)) {
+				addr = rsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(rsdt);
+	}
+	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
+	if (addr == 0) {
+		if (bootverbose)
+			printf("ACPI: No %s table found\n", sig);
+		return (0);
+	}
+	if (bootverbose)
+		printf("%s: Found table at 0x%jx\n", sig, (uintmax_t)addr);
+
+	/*
+	 * Verify that we can map the full table and that its checksum is
+	 * correct, etc.
+	 */
+	table = map_table(addr, 0, sig);
+	if (table == NULL)
+		return (0);
+	acpi_unmap_table(table);
+
+	return (addr);
+}
+
+/*
  * ACPI nexus(4) driver.
  */
 static int

Modified: stable/8/sys/i386/acpica/madt.c
==============================================================================
--- stable/8/sys/i386/acpica/madt.c	Thu Oct 29 15:59:27 2009	(r198609)
+++ stable/8/sys/i386/acpica/madt.c	Thu Oct 29 16:00:27 2009	(r198610)
@@ -36,27 +36,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
-#include 
 #include 
 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
-#include 
 #include 
 
 #include 
 #include 
 
-typedef	void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
-
 /* These two arrays are indexed by APIC IDs. */
 struct ioapic_info {
 	void *io_apic;
@@ -79,8 +71,6 @@ static enum intr_polarity interrupt_pola
 static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
 static int	madt_find_cpu(u_int acpi_id, u_int *apic_id);
 static int	madt_find_interrupt(int intr, void **apic, u_int *pin);
-static void	*madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
-static void	*madt_map_table(vm_paddr_t pa, int offset, const char *sig);
 static void	madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
 static void	madt_parse_interrupt_override(
 		    ACPI_MADT_INTERRUPT_OVERRIDE *intr);
@@ -92,13 +82,10 @@ static int	madt_probe(void);
 static int	madt_probe_cpus(void);
 static void	madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
 		    void *arg __unused);
-static int	madt_probe_table(vm_paddr_t address);
 static void	madt_register(void *dummy);
 static int	madt_setup_local(void);
 static int	madt_setup_io(void);
-static void	madt_unmap(void *data, vm_offset_t length);
-static void	madt_unmap_table(void *table);
-static void	madt_walk_table(madt_entry_handler *handler, void *arg);
+static void	madt_walk_table(acpi_subtable_handler *handler, void *arg);
 
 static struct apic_enumerator madt_enumerator = {
 	"MADT",
@@ -108,87 +95,6 @@ static struct apic_enumerator madt_enume
 	madt_setup_io
 };
 
-/*
- * Code to abuse the crashdump map to map in the tables for the early
- * probe.  We cheat and make the following assumptions about how we
- * use this KVA: pages 0 and 1 are used to map in the header of each
- * table found via the RSDT or XSDT and pages 2 to n are used to map
- * in the RSDT or XSDT.  We have to use 2 pages for the table headers
- * in case a header spans a page boundary.  The offset is in pages;
- * the length is in bytes.
- */
-static void *
-madt_map(vm_paddr_t pa, int offset, vm_offset_t length)
-{
-	vm_offset_t va, off;
-	void *data;
-
-	off = pa & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	pa = pa & PG_FRAME;
-	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
-	    (offset * PAGE_SIZE);
-	data = (void *)(va + off);
-	length -= PAGE_SIZE;
-	while (length > 0) {
-		va += PAGE_SIZE;
-		pa += PAGE_SIZE;
-		length -= PAGE_SIZE;
-		pmap_kenter(va, pa);
-		invlpg(va);
-	}
-	return (data);
-}
-
-static void
-madt_unmap(void *data, vm_offset_t length)
-{
-	vm_offset_t va, off;
-
-	va = (vm_offset_t)data;
-	off = va & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	va &= ~PAGE_MASK;
-	while (length > 0) {
-		pmap_kremove(va);
-		invlpg(va);
-		va += PAGE_SIZE;
-		length -= PAGE_SIZE;
-	}
-}
-
-static void *
-madt_map_table(vm_paddr_t pa, int offset, const char *sig)
-{
-	ACPI_TABLE_HEADER *header;
-	vm_offset_t length;
-	void *table;
-

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:19:58 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9D3E01065695;
	Thu, 29 Oct 2009 16:19:58 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 89B968FC12;
	Thu, 29 Oct 2009 16:19:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGJwxG002884;
	Thu, 29 Oct 2009 16:19:58 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGJwZ4002878;
	Thu, 29 Oct 2009 16:19:58 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200910291619.n9TGJwZ4002878@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 29 Oct 2009 16:19:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198611 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris conf contrib/dev/acpica contrib/pf
	dev/xen/xenpci fs/procfs modules/procfs
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:19:58 -0000

Author: kib
Date: Thu Oct 29 16:19:58 2009
New Revision: 198611
URL: http://svn.freebsd.org/changeset/base/198611

Log:
  MFC r197428:
  Add per-process osrel node to the procfs, to allow read and set p_osrel
  value for the process.

Added:
  stable/8/sys/fs/procfs/procfs_osrel.c
     - copied unchanged from r197428, head/sys/fs/procfs/procfs_osrel.c
Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/conf/files
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/fs/procfs/procfs.c
  stable/8/sys/fs/procfs/procfs.h
  stable/8/sys/modules/procfs/Makefile

Modified: stable/8/sys/conf/files
==============================================================================
--- stable/8/sys/conf/files	Thu Oct 29 16:00:27 2009	(r198610)
+++ stable/8/sys/conf/files	Thu Oct 29 16:19:58 2009	(r198611)
@@ -1787,6 +1787,7 @@ fs/procfs/procfs_ioctl.c	optional procfs
 fs/procfs/procfs_map.c		optional procfs
 fs/procfs/procfs_mem.c		optional procfs
 fs/procfs/procfs_note.c		optional procfs
+fs/procfs/procfs_osrel.c	optional procfs
 fs/procfs/procfs_regs.c		optional procfs
 fs/procfs/procfs_rlimit.c	optional procfs
 fs/procfs/procfs_status.c	optional procfs

Modified: stable/8/sys/fs/procfs/procfs.c
==============================================================================
--- stable/8/sys/fs/procfs/procfs.c	Thu Oct 29 16:00:27 2009	(r198610)
+++ stable/8/sys/fs/procfs/procfs.c	Thu Oct 29 16:19:58 2009	(r198611)
@@ -108,7 +108,8 @@ procfs_attr(PFS_ATTR_ARGS)
 	else if (strcmp(pn->pn_name, "mem") == 0 ||
 	    strcmp(pn->pn_name, "regs") == 0 ||
 	    strcmp(pn->pn_name, "dbregs") == 0 ||
-	    strcmp(pn->pn_name, "fpregs") == 0)
+	    strcmp(pn->pn_name, "fpregs") == 0 ||
+	    strcmp(pn->pn_name, "osrel") == 0)
 		vap->va_mode = 0600;
 
 	if (p != NULL) {
@@ -186,6 +187,8 @@ procfs_init(PFS_INIT_ARGS)
 	    NULL, NULL, NULL, PFS_RD);
 	pfs_create_file(dir, "status", procfs_doprocstatus,
 	    NULL, NULL, NULL, PFS_RD);
+	pfs_create_file(dir, "osrel", procfs_doosrel,
+	    procfs_attr, procfs_candebug, NULL, PFS_RDWR);
 
 	pfs_create_link(dir, "file", procfs_doprocfile,
 	    NULL, procfs_notsystem, NULL, 0);

Modified: stable/8/sys/fs/procfs/procfs.h
==============================================================================
--- stable/8/sys/fs/procfs/procfs.h	Thu Oct 29 16:00:27 2009	(r198610)
+++ stable/8/sys/fs/procfs/procfs.h	Thu Oct 29 16:19:58 2009	(r198611)
@@ -39,6 +39,7 @@
 #ifdef _KERNEL
 
 int	 procfs_docurproc(PFS_FILL_ARGS);
+int	 procfs_doosrel(PFS_FILL_ARGS);
 int	 procfs_doproccmdline(PFS_FILL_ARGS);
 int	 procfs_doprocctl(PFS_FILL_ARGS);
 int	 procfs_doprocdbregs(PFS_FILL_ARGS);

Copied: stable/8/sys/fs/procfs/procfs_osrel.c (from r197428, head/sys/fs/procfs/procfs_osrel.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/sys/fs/procfs/procfs_osrel.c	Thu Oct 29 16:19:58 2009	(r198611, copy of r197428, head/sys/fs/procfs/procfs_osrel.c)
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2009 Konstantin Belousov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+int
+procfs_doosrel(PFS_FILL_ARGS)
+{
+	const char *pp;
+	int ov, osrel, i;
+
+	if (uio == NULL)
+		return (EOPNOTSUPP);
+	if (uio->uio_rw == UIO_READ) {
+		sbuf_printf(sb, "%d\n", p->p_osrel);
+	} else {
+		sbuf_trim(sb);
+		sbuf_finish(sb);
+		pp = sbuf_data(sb);
+		osrel = 0;
+		i = sbuf_len(sb);
+		while (i--) {
+			if (*pp < '0' || *pp > '9')
+				return (EINVAL);
+			ov = osrel * 10 + *pp++ - '0';
+			if (ov < osrel)
+				return (EINVAL);
+			osrel = ov;
+		}
+		p->p_osrel = osrel;
+	}
+	return (0);
+}

Modified: stable/8/sys/modules/procfs/Makefile
==============================================================================
--- stable/8/sys/modules/procfs/Makefile	Thu Oct 29 16:00:27 2009	(r198610)
+++ stable/8/sys/modules/procfs/Makefile	Thu Oct 29 16:19:58 2009	(r198611)
@@ -13,6 +13,7 @@ SRCS+=		procfs_ioctl.c
 SRCS+=		procfs_map.c
 SRCS+=		procfs_mem.c
 SRCS+=		procfs_note.c
+SRCS+=		procfs_osrel.c
 SRCS+=		procfs_regs.c
 SRCS+=		procfs_rlimit.c
 SRCS+=		procfs_status.c

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:21:53 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5372C106568D;
	Thu, 29 Oct 2009 16:21:53 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 42A218FC18;
	Thu, 29 Oct 2009 16:21:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGLrs2002986;
	Thu, 29 Oct 2009 16:21:53 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGLrcw002984;
	Thu, 29 Oct 2009 16:21:53 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200910291621.n9TGLrcw002984@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 29 Oct 2009 16:21:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198612 - stable/8/share/man/man5
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:21:53 -0000

Author: kib
Date: Thu Oct 29 16:21:52 2009
New Revision: 198612
URL: http://svn.freebsd.org/changeset/base/198612

Log:
  MFC r197429:
  Document osrel node for procfs.

Modified:
  stable/8/share/man/man5/   (props changed)
  stable/8/share/man/man5/procfs.5

Modified: stable/8/share/man/man5/procfs.5
==============================================================================
--- stable/8/share/man/man5/procfs.5	Thu Oct 29 16:19:58 2009	(r198611)
+++ stable/8/share/man/man5/procfs.5	Thu Oct 29 16:21:52 2009	(r198612)
@@ -2,7 +2,7 @@
 .\" Written by Garrett Wollman
 .\" This file is in the public domain.
 .\"
-.Dd July 9, 2009
+.Dd September 22, 2009
 .Dt PROCFS 5
 .Os
 .Sh NAME
@@ -117,6 +117,12 @@ Not implemented.
 .It Pa notepg
 Used for sending signal to the process group.
 Not implemented.
+.It Pa osrel
+Allows read and write of the kernel osrel value assigned to the process.
+It affects the compatibility shims that are turned on and off
+depending on the value.
+Initial process value is read from the ABI note tag in the executed ELF image,
+and is zero if the tag not supported by binary format or was not found.
 .It Pa regs
 Allows read and write access to the process' register set.
 This file contains a binary data structure
@@ -237,6 +243,8 @@ the complete virtual address space of th
 used for signaling the process
 .It Pa /proc/curproc/notepg
 used for signaling the process group
+.It Pa /proc/curproc/osrel
+the process osrel value
 .It Pa /proc/curproc/regs
 the process register set
 .It Pa /proc/curproc/rlimit

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:24:39 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AC04D106566B;
	Thu, 29 Oct 2009 16:24:39 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9925D8FC0A;
	Thu, 29 Oct 2009 16:24:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGOdoc003099;
	Thu, 29 Oct 2009 16:24:39 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGOd40003096;
	Thu, 29 Oct 2009 16:24:39 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200910291624.n9TGOd40003096@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 29 Oct 2009 16:24:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198613 - in stable/8/sys: . amd64/amd64
	amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica
	contrib/pf dev/xen/xenpci i386/i386
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:24:39 -0000

Author: kib
Date: Thu Oct 29 16:24:39 2009
New Revision: 198613
URL: http://svn.freebsd.org/changeset/base/198613

Log:
  MFC r197389:
  Do panic regardeless of execution mode at the moment of T_RESERVED trap.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/amd64/trap.c
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/i386/i386/trap.c

Modified: stable/8/sys/amd64/amd64/trap.c
==============================================================================
--- stable/8/sys/amd64/amd64/trap.c	Thu Oct 29 16:21:52 2009	(r198612)
+++ stable/8/sys/amd64/amd64/trap.c	Thu Oct 29 16:24:39 2009	(r198613)
@@ -253,6 +253,11 @@ trap(struct trapframe *frame)
 	}
 #endif
 
+	if (type == T_RESERVED) {
+		trap_fatal(frame, 0);
+		goto out;
+	}
+
 #ifdef	HWPMC_HOOKS
 	/*
 	 * CPU PMCs interrupt using an NMI.  If the PMC module is

Modified: stable/8/sys/i386/i386/trap.c
==============================================================================
--- stable/8/sys/i386/i386/trap.c	Thu Oct 29 16:21:52 2009	(r198612)
+++ stable/8/sys/i386/i386/trap.c	Thu Oct 29 16:24:39 2009	(r198613)
@@ -225,6 +225,11 @@ trap(struct trapframe *frame)
 	}
 #endif
 
+	if (type == T_RESERVED) {
+		trap_fatal(frame, 0);
+		goto out;
+	}
+
 #ifdef	HWPMC_HOOKS
 	/*
 	 * CPU PMCs interrupt using an NMI so we check for that first.

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:28:21 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5E466106568D;
	Thu, 29 Oct 2009 16:28:21 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4BEEB8FC17;
	Thu, 29 Oct 2009 16:28:21 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGSL2N003229;
	Thu, 29 Oct 2009 16:28:21 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGSL4e003227;
	Thu, 29 Oct 2009 16:28:21 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200910291628.n9TGSL4e003227@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 29 Oct 2009 16:28:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198614 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci kern
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:28:21 -0000

Author: kib
Date: Thu Oct 29 16:28:21 2009
New Revision: 198614
URL: http://svn.freebsd.org/changeset/base/198614

Log:
  MFC r197930:
  Postpone dropping fp till both kq_global and kqueue mutexes are
  unlocked.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/kern_event.c

Modified: stable/8/sys/kern/kern_event.c
==============================================================================
--- stable/8/sys/kern/kern_event.c	Thu Oct 29 16:24:39 2009	(r198613)
+++ stable/8/sys/kern/kern_event.c	Thu Oct 29 16:28:21 2009	(r198614)
@@ -909,13 +909,13 @@ findkn:
 
 	/* knote is in the process of changing, wait for it to stablize. */
 	if (kn != NULL && (kn->kn_status & KN_INFLUX) == KN_INFLUX) {
+		KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal);
+		kq->kq_state |= KQ_FLUXWAIT;
+		msleep(kq, &kq->kq_lock, PSOCK | PDROP, "kqflxwt", 0);
 		if (fp != NULL) {
 			fdrop(fp, td);
 			fp = NULL;
 		}
-		KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal);
-		kq->kq_state |= KQ_FLUXWAIT;
-		msleep(kq, &kq->kq_lock, PSOCK | PDROP, "kqflxwt", 0);
 		goto findkn;
 	}
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:30:48 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7192E1065676;
	Thu, 29 Oct 2009 16:30:48 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 608628FC20;
	Thu, 29 Oct 2009 16:30:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGUm2J003341;
	Thu, 29 Oct 2009 16:30:48 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGUmQ0003339;
	Thu, 29 Oct 2009 16:30:48 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910291630.n9TGUmQ0003339@svn.freebsd.org>
From: Christian Brueffer 
Date: Thu, 29 Oct 2009 16:30:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198615 - in stable/8/etc: . defaults
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:30:48 -0000

Author: brueffer
Date: Thu Oct 29 16:30:48 2009
New Revision: 198615
URL: http://svn.freebsd.org/changeset/base/198615

Log:
  MFC: r198314
  
  Add empty watchdogd_flags.

Modified:
  stable/8/etc/   (props changed)
  stable/8/etc/defaults/rc.conf

Modified: stable/8/etc/defaults/rc.conf
==============================================================================
--- stable/8/etc/defaults/rc.conf	Thu Oct 29 16:28:21 2009	(r198614)
+++ stable/8/etc/defaults/rc.conf	Thu Oct 29 16:30:48 2009	(r198615)
@@ -597,6 +597,7 @@ harvest_ethernet="YES"	# Entropy device 
 harvest_p_to_p="YES"	# Entropy device harvests point-to-point randomness
 dmesg_enable="YES"	# Save dmesg(8) to /var/run/dmesg.boot
 watchdogd_enable="NO"	# Start the software watchdog daemon
+watchdogd_flags=""	# Flags to watchdogd (if enabled)
 devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing
 							    # devfs(8) rules.
 devfs_system_ruleset=""	# The name (NOT number) of a ruleset to apply to /dev

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 16:39:27 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A268C106566B;
	Thu, 29 Oct 2009 16:39:27 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 912348FC15;
	Thu, 29 Oct 2009 16:39:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TGdRhw003616;
	Thu, 29 Oct 2009 16:39:27 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TGdRpV003614;
	Thu, 29 Oct 2009 16:39:27 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910291639.n9TGdRpV003614@svn.freebsd.org>
From: Christian Brueffer 
Date: Thu, 29 Oct 2009 16:39:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198616 - in stable/7/etc: . defaults
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 16:39:27 -0000

Author: brueffer
Date: Thu Oct 29 16:39:27 2009
New Revision: 198616
URL: http://svn.freebsd.org/changeset/base/198616

Log:
  MFC: r198314
  
  Add empty watchdogd_flags.

Modified:
  stable/7/etc/   (props changed)
  stable/7/etc/defaults/rc.conf
  stable/7/etc/termcap.small   (props changed)

Modified: stable/7/etc/defaults/rc.conf
==============================================================================
--- stable/7/etc/defaults/rc.conf	Thu Oct 29 16:30:48 2009	(r198615)
+++ stable/7/etc/defaults/rc.conf	Thu Oct 29 16:39:27 2009	(r198616)
@@ -592,6 +592,7 @@ harvest_ethernet="YES"	# Entropy device 
 harvest_p_to_p="YES"	# Entropy device harvests point-to-point randomness
 dmesg_enable="YES"	# Save dmesg(8) to /var/run/dmesg.boot
 watchdogd_enable="NO"	# Start the software watchdog daemon
+watchdogd_flags=""	# Flags to watchdogd (if enabled)
 devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing
 							    # devfs(8) rules.
 devfs_system_ruleset=""	# The name (NOT number) of a ruleset to apply to /dev

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 17:15:22 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7CC0E106566C;
	Thu, 29 Oct 2009 17:15:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6942D8FC0C;
	Thu, 29 Oct 2009 17:15:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9THFMB3004504;
	Thu, 29 Oct 2009 17:15:22 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9THFMIq004495;
	Thu, 29 Oct 2009 17:15:22 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910291715.n9THFMIq004495@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 29 Oct 2009 17:15:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198618 - in stable/7/sys: . amd64/acpica amd64/include
	contrib/pf dev/acpica i386/acpica i386/include
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 17:15:22 -0000

Author: jhb
Date: Thu Oct 29 17:15:22 2009
New Revision: 198618
URL: http://svn.freebsd.org/changeset/base/198618

Log:
  MFC 197439:
  Extract the code to find and map the MADT ACPI table during early kernel
  startup and genericize it so it can be reused to map other tables as well:
  - Add a routine to walk a list of ACPI subtables such as those used in the
    APIC and SRAT tables in the MI acpi(4) driver.
  - Move the routines for mapping and unmapping an ACPI table as well as
    mapping the RSDT or XSDT and searching for a table with a given signature
    out into acpica_machdep.c for both amd64 and i386.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/acpica/acpi_machdep.c
  stable/7/sys/amd64/acpica/madt.c
  stable/7/sys/amd64/include/acpica_machdep.h
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/acpica/acpi.c
  stable/7/sys/dev/acpica/acpivar.h
  stable/7/sys/i386/acpica/acpi_machdep.c
  stable/7/sys/i386/acpica/madt.c
  stable/7/sys/i386/include/acpica_machdep.h

Modified: stable/7/sys/amd64/acpica/acpi_machdep.c
==============================================================================
--- stable/7/sys/amd64/acpica/acpi_machdep.c	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/amd64/acpica/acpi_machdep.c	Thu Oct 29 17:15:22 2009	(r198618)
@@ -29,8 +29,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
+#include 
 
 #include 
+#include 
+
 #include 
 
 static int intr_model = ACPI_INTR_PIC;
@@ -67,3 +71,243 @@ acpi_cpu_c1()
 {
 	__asm __volatile("sti; hlt");
 }
+
+/*
+ * Support for mapping ACPI tables during early boot.  Currently this
+ * uses the crashdump map to map each table.  However, the crashdump
+ * map is created in pmap_bootstrap() right after the direct map, so
+ * we should be able to just use pmap_mapbios() here instead.
+ *
+ * This makes the following assumptions about how we use this KVA:
+ * pages 0 and 1 are used to map in the header of each table found via
+ * the RSDT or XSDT and pages 2 to n are used to map in the RSDT or
+ * XSDT.  This has to use 2 pages for the table headers in case a
+ * header spans a page boundary.
+ *
+ * XXX: We don't ensure the table fits in the available address space
+ * in the crashdump map.
+ */
+
+/*
+ * Map some memory using the crashdump map.  'offset' is an offset in
+ * pages into the crashdump map to use for the start of the mapping.
+ */
+static void *
+table_map(vm_paddr_t pa, int offset, vm_offset_t length)
+{
+	vm_offset_t va, off;
+	void *data;
+
+	off = pa & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	pa = pa & PG_FRAME;
+	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
+	    (offset * PAGE_SIZE);
+	data = (void *)(va + off);
+	length -= PAGE_SIZE;
+	while (length > 0) {
+		va += PAGE_SIZE;
+		pa += PAGE_SIZE;
+		length -= PAGE_SIZE;
+		pmap_kenter(va, pa);
+		invlpg(va);
+	}
+	return (data);
+}
+
+/* Unmap memory previously mapped with table_map(). */
+static void
+table_unmap(void *data, vm_offset_t length)
+{
+	vm_offset_t va, off;
+
+	va = (vm_offset_t)data;
+	off = va & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	va &= ~PAGE_MASK;
+	while (length > 0) {
+		pmap_kremove(va);
+		invlpg(va);
+		va += PAGE_SIZE;
+		length -= PAGE_SIZE;
+	}
+}
+
+/*
+ * Map a table at a given offset into the crashdump map.  It first
+ * maps the header to determine the table length and then maps the
+ * entire table.
+ */
+static void *
+map_table(vm_paddr_t pa, int offset, const char *sig)
+{
+	ACPI_TABLE_HEADER *header;
+	vm_offset_t length;
+	void *table;
+
+	header = table_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
+	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+		return (NULL);
+	}
+	length = header->Length;
+	table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+	table = table_map(pa, offset, length);
+	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
+		if (bootverbose)
+			printf("ACPI: Failed checksum for table %s\n", sig);
+		table_unmap(table, length);
+		return (NULL);
+	}
+	return (table);
+}
+
+/*
+ * See if a given ACPI table is the requested table.  Returns the
+ * length of the able if it matches or zero on failure.
+ */
+static int
+probe_table(vm_paddr_t address, const char *sig)
+{
+	ACPI_TABLE_HEADER *table;
+
+	table = table_map(address, 0, sizeof(ACPI_TABLE_HEADER));
+	if (table == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map table at 0x%jx\n",
+			    (uintmax_t)address);
+		return (0);
+	}
+	if (bootverbose)
+		printf("Table '%.4s' at 0x%jx\n", table->Signature,
+		    (uintmax_t)address);
+
+	if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+		return (0);
+	}
+	table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+	return (1);
+}
+
+/*
+ * Try to map a table at a given physical address previously returned
+ * by acpi_find_table().
+ */
+void *
+acpi_map_table(vm_paddr_t pa, const char *sig)
+{
+
+	return (map_table(pa, 0, sig));
+}
+
+/* Unmap a table previously mapped via acpi_map_table(). */
+void
+acpi_unmap_table(void *table)
+{
+	ACPI_TABLE_HEADER *header;
+
+	header = (ACPI_TABLE_HEADER *)table;
+	table_unmap(table, header->Length);
+}
+
+/*
+ * Return the physical address of the requested table or zero if one
+ * is not found.
+ */
+vm_paddr_t
+acpi_find_table(const char *sig)
+{
+	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *table;
+	vm_paddr_t addr;
+	int i, count;
+
+	if (resource_disabled("acpi", 0))
+		return (0);
+
+	/*
+	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
+	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
+	 * pmap_mapbios() to map the RSDP.
+	 */
+	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+		return (0);
+	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
+	if (rsdp == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map RSDP\n");
+		return (0);
+	}
+
+	/*
+	 * For ACPI >= 2.0, use the XSDT if it is available.
+	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 2
+	 * in the crashdump area.  Pages 0 and 1 are used to map in the
+	 * headers of candidate ACPI tables.
+	 */
+	addr = 0;
+	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
+		/*
+		 * AcpiOsGetRootPointer only verifies the checksum for
+		 * the version 1.0 portion of the RSDP.  Version 2.0 has
+		 * an additional checksum that we verify first.
+		 */
+		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
+			if (bootverbose)
+				printf("ACPI: RSDP failed extended checksum\n");
+			return (0);
+		}
+		xsdt = map_table(rsdp->XsdtPhysicalAddress, 2, ACPI_SIG_XSDT);
+		if (xsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map XSDT\n");
+			return (0);
+		}
+		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT64);
+		for (i = 0; i < count; i++)
+			if (probe_table(xsdt->TableOffsetEntry[i], sig)) {
+				addr = xsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(xsdt);
+	} else {
+		rsdt = map_table(rsdp->RsdtPhysicalAddress, 2, ACPI_SIG_RSDT);
+		if (rsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map RSDT\n");
+			return (0);
+		}
+		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT32);
+		for (i = 0; i < count; i++)
+			if (probe_table(rsdt->TableOffsetEntry[i], sig)) {
+				addr = rsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(rsdt);
+	}
+	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
+	if (addr == 0) {
+		if (bootverbose)
+			printf("ACPI: No %s table found\n", sig);
+		return (0);
+	}
+	if (bootverbose)
+		printf("%s: Found table at 0x%jx\n", sig, (uintmax_t)addr);
+
+	/*
+	 * Verify that we can map the full table and that its checksum is
+	 * correct, etc.
+	 */
+	table = map_table(addr, 0, sig);
+	if (table == NULL)
+		return (0);
+	acpi_unmap_table(table);
+
+	return (addr);
+}

Modified: stable/7/sys/amd64/acpica/madt.c
==============================================================================
--- stable/7/sys/amd64/acpica/madt.c	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/amd64/acpica/madt.c	Thu Oct 29 17:15:22 2009	(r198618)
@@ -36,25 +36,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
-#include 
 #include 
 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
+
 #include 
 #include 
 
-typedef	void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
-
 /* These two arrays are indexed by APIC IDs. */
 struct ioapic_info {
 	void *io_apic;
@@ -77,8 +71,6 @@ static enum intr_polarity interrupt_pola
 static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
 static int	madt_find_cpu(u_int acpi_id, u_int *apic_id);
 static int	madt_find_interrupt(int intr, void **apic, u_int *pin);
-static void	*madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
-static void	*madt_map_table(vm_paddr_t pa, int offset, const char *sig);
 static void	madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
 static void	madt_parse_interrupt_override(
 		    ACPI_MADT_INTERRUPT_OVERRIDE *intr);
@@ -90,13 +82,10 @@ static int	madt_probe(void);
 static int	madt_probe_cpus(void);
 static void	madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
 		    void *arg __unused);
-static int	madt_probe_table(vm_paddr_t address);
 static void	madt_register(void *dummy);
 static int	madt_setup_local(void);
 static int	madt_setup_io(void);
-static void	madt_unmap(void *data, vm_offset_t length);
-static void	madt_unmap_table(void *table);
-static void	madt_walk_table(madt_entry_handler *handler, void *arg);
+static void	madt_walk_table(acpi_subtable_handler *handler, void *arg);
 
 static struct apic_enumerator madt_enumerator = {
 	"MADT",
@@ -107,224 +96,30 @@ static struct apic_enumerator madt_enume
 };
 
 /*
- * Code to abuse the crashdump map to map in the tables for the early
- * probe.  We cheat and make the following assumptions about how we
- * use this KVA: pages 0 and 1 are used to map in the header of each
- * table found via the RSDT or XSDT and pages 2 to n are used to map
- * in the RSDT or XSDT.  We have to use 2 pages for the table headers
- * in case a header spans a page boundary.  The offset is in pages;
- * the length is in bytes.
- */
-static void *
-madt_map(vm_paddr_t pa, int offset, vm_offset_t length)
-{
-	vm_offset_t va, off;
-	void *data;
-
-	off = pa & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	pa = pa & PG_FRAME;
-	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
-	    (offset * PAGE_SIZE);
-	data = (void *)(va + off);
-	length -= PAGE_SIZE;
-	while (length > 0) {
-		va += PAGE_SIZE;
-		pa += PAGE_SIZE;
-		length -= PAGE_SIZE;
-		pmap_kenter(va, pa);
-		invlpg(va);
-	}
-	return (data);
-}
-
-static void
-madt_unmap(void *data, vm_offset_t length)
-{
-	vm_offset_t va, off;
-
-	va = (vm_offset_t)data;
-	off = va & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	va &= ~PAGE_MASK;
-	while (length > 0) {
-		pmap_kremove(va);
-		invlpg(va);
-		va += PAGE_SIZE;
-		length -= PAGE_SIZE;
-	}
-}
-
-static void *
-madt_map_table(vm_paddr_t pa, int offset, const char *sig)
-{
-	ACPI_TABLE_HEADER *header;
-	vm_offset_t length;
-	void *table;
-
-	header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
-	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
-		madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-		return (NULL);
-	}
-	length = header->Length;
-	madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-	table = madt_map(pa, offset, length);
-	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
-		if (bootverbose)
-			printf("MADT: Failed checksum for table %s\n", sig);
-		madt_unmap(table, length);
-		return (NULL);
-	}
-	return (table);
-}
-
-static void
-madt_unmap_table(void *table)
-{
-	ACPI_TABLE_HEADER *header;
-
-	header = (ACPI_TABLE_HEADER *)table;
-	madt_unmap(table, header->Length);
-}
-
-/*
  * Look for an ACPI Multiple APIC Description Table ("APIC")
  */
 static int
 madt_probe(void)
 {
-	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
-	ACPI_TABLE_RSDP *rsdp;
-	ACPI_TABLE_RSDT *rsdt;
-	ACPI_TABLE_XSDT *xsdt;
-	int i, count;
-
-	if (resource_disabled("acpi", 0))
-		return (ENXIO);
-
-	/*
-	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
-	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
-	 * pmap_mapbios() to map the RSDP.
-	 */
-	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
-		return (ENXIO);
-	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
-	if (rsdp == NULL) {
-		if (bootverbose)
-			printf("MADT: Failed to map RSDP\n");
-		return (ENXIO);
-	}
-
-	/*
-	 * For ACPI >= 2.0, use the XSDT if it is available.
-	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 1
-	 * in the crashdump area.  Page 0 is used to map in the
-	 * headers of candidate ACPI tables.
-	 */
-	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
-		/*
-		 * AcpiOsGetRootPointer only verifies the checksum for
-		 * the version 1.0 portion of the RSDP.  Version 2.0 has
-		 * an additional checksum that we verify first.
-		 */
-		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
-			if (bootverbose)
-				printf("MADT: RSDP failed extended checksum\n");
-			return (ENXIO);
-		}
-		xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 2,
-		    ACPI_SIG_XSDT);
-		if (xsdt == NULL) {
-			if (bootverbose)
-				printf("MADT: Failed to map XSDT\n");
-			return (ENXIO);
-		}
-		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
-		    sizeof(UINT64);
-		for (i = 0; i < count; i++)
-			if (madt_probe_table(xsdt->TableOffsetEntry[i]))
-				break;
-		madt_unmap_table(xsdt);
-	} else {
-		rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 2,
-		    ACPI_SIG_RSDT);
-		if (rsdt == NULL) {
-			if (bootverbose)
-				printf("MADT: Failed to map RSDT\n");
-			return (ENXIO);
-		}
-		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
-		    sizeof(UINT32);
-		for (i = 0; i < count; i++)
-			if (madt_probe_table(rsdt->TableOffsetEntry[i]))
-				break;
-		madt_unmap_table(rsdt);
-	}
-	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
-	if (madt_physaddr == 0) {
-		if (bootverbose)
-			printf("MADT: No MADT table found\n");
-		return (ENXIO);
-	}
-	if (bootverbose)
-		printf("MADT: Found table at 0x%jx\n",
-		    (uintmax_t)madt_physaddr);
 
-	/*
-	 * Verify that we can map the full table and that its checksum is
-	 * correct, etc.
-	 */
-	madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
-	if (madt == NULL)
+	madt_physaddr = acpi_find_table(ACPI_SIG_MADT);
+	if (madt_physaddr == 0)
 		return (ENXIO);
-	madt_unmap_table(madt);
-	madt = NULL;
-
 	return (0);
 }
 
 /*
- * See if a given ACPI table is the MADT.
- */
-static int
-madt_probe_table(vm_paddr_t address)
-{
-	ACPI_TABLE_HEADER *table;
-
-	table = madt_map(address, 0, sizeof(ACPI_TABLE_HEADER));
-	if (table == NULL) {
-		if (bootverbose)
-			printf("MADT: Failed to map table at 0x%jx\n",
-			    (uintmax_t)address);
-		return (0);
-	}
-	if (bootverbose)
-		printf("Table '%.4s' at 0x%jx\n", table->Signature,
-		    (uintmax_t)address);
-
-	if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) {
-		madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
-		return (0);
-	}
-	madt_physaddr = address;
-	madt_length = table->Length;
-	madt_unmap(table, sizeof(ACPI_TABLE_HEADER));
-	return (1);
-}
-
-/*
  * Run through the MP table enumerating CPUs.
  */
 static int
 madt_probe_cpus(void)
 {
 
-	madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT);
+	madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT);
+	madt_length = madt->Header.Length;
 	KASSERT(madt != NULL, ("Unable to re-map MADT"));
 	madt_walk_table(madt_probe_cpus_handler, NULL);
-	madt_unmap_table(madt);
+	acpi_unmap_table(madt);
 	madt = NULL;
 	return (0);
 }
@@ -415,17 +210,11 @@ SYSINIT(madt_register, SI_SUB_TUNABLES -
  * Call the handler routine for each entry in the MADT table.
  */
 static void
-madt_walk_table(madt_entry_handler *handler, void *arg)
+madt_walk_table(acpi_subtable_handler *handler, void *arg)
 {
-	ACPI_SUBTABLE_HEADER *entry;
-	u_char *p, *end;
 
-	end = (u_char *)(madt) + madt->Header.Length;
-	for (p = (u_char *)(madt + 1); p < end; ) {
-		entry = (ACPI_SUBTABLE_HEADER *)p;
-		handler(entry, arg);
-		p += entry->Length;
-	}
+	acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
+	    handler, arg);
 }
 
 static void

Modified: stable/7/sys/amd64/include/acpica_machdep.h
==============================================================================
--- stable/7/sys/amd64/include/acpica_machdep.h	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/amd64/include/acpica_machdep.h	Thu Oct 29 17:15:22 2009	(r198618)
@@ -77,5 +77,8 @@ extern int	acpi_release_global_lock(uint
 
 void	acpi_SetDefaultIntrModel(int model);
 void	acpi_cpu_c1(void);
+void	*acpi_map_table(vm_paddr_t pa, const char *sig);
+void	acpi_unmap_table(void *table);
+vm_paddr_t acpi_find_table(const char *sig);
 
 #endif /* __ACPICA_MACHDEP_H__ */

Modified: stable/7/sys/dev/acpica/acpi.c
==============================================================================
--- stable/7/sys/dev/acpica/acpi.c	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/dev/acpica/acpi.c	Thu Oct 29 17:15:22 2009	(r198618)
@@ -2166,6 +2166,28 @@ acpi_SetIntrModel(int model)
 }
 
 /*
+ * Walk subtables of a table and call a callback routine for each
+ * subtable.  The caller should provide the first subtable and a
+ * pointer to the end of the table.  This can be used to walk tables
+ * such as MADT and SRAT that use subtable entries.
+ */
+void
+acpi_walk_subtables(void *first, void *end, acpi_subtable_handler *handler,
+    void *arg)
+{
+    ACPI_SUBTABLE_HEADER *entry;
+
+    for (entry = first; (void *)entry < end; ) {
+	/* Avoid an infinite loop if we hit a bogus entry. */
+	if (entry->Length < sizeof(ACPI_SUBTABLE_HEADER))
+	    return;
+
+	handler(entry, arg);
+	entry = ACPI_ADD_PTR(ACPI_SUBTABLE_HEADER, entry, entry->Length);
+    }
+}
+
+/*
  * DEPRECATED.  This interface has serious deficiencies and will be
  * removed.
  *

Modified: stable/7/sys/dev/acpica/acpivar.h
==============================================================================
--- stable/7/sys/dev/acpica/acpivar.h	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/dev/acpica/acpivar.h	Thu Oct 29 17:15:22 2009	(r198618)
@@ -307,6 +307,9 @@ void		acpi_EnterDebugger(void);
 	ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL | \
 	    ACPI_STA_BATT_PRESENT)
 
+/* Callback function type for walking subtables within a table. */
+typedef void acpi_subtable_handler(ACPI_SUBTABLE_HEADER *, void *);
+
 BOOLEAN		acpi_DeviceIsPresent(device_t dev);
 BOOLEAN		acpi_BatteryIsPresent(device_t dev);
 ACPI_STATUS	acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
@@ -339,6 +342,8 @@ void		acpi_UserNotify(const char *subsys
 int		acpi_bus_alloc_gas(device_t dev, int *type, int *rid,
 		    ACPI_GENERIC_ADDRESS *gas, struct resource **res,
 		    u_int flags);
+void		acpi_walk_subtables(void *first, void *end,
+		    acpi_subtable_handler *handler, void *arg);
 
 struct acpi_parse_resource_set {
     void	(*set_init)(device_t dev, void *arg, void **context);

Modified: stable/7/sys/i386/acpica/acpi_machdep.c
==============================================================================
--- stable/7/sys/i386/acpica/acpi_machdep.c	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/i386/acpica/acpi_machdep.c	Thu Oct 29 17:15:22 2009	(r198618)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+
 #include 
 #include 
 
@@ -549,3 +551,241 @@ acpi_cpu_c1()
 {
 	__asm __volatile("sti; hlt");
 }
+
+/*
+ * Support for mapping ACPI tables during early boot.  This abuses the
+ * crashdump map because the kernel cannot allocate KVA in
+ * pmap_mapbios() when this is used.  This makes the following
+ * assumptions about how we use this KVA: pages 0 and 1 are used to
+ * map in the header of each table found via the RSDT or XSDT and
+ * pages 2 to n are used to map in the RSDT or XSDT.  This has to use
+ * 2 pages for the table headers in case a header spans a page
+ * boundary.
+ *
+ * XXX: We don't ensure the table fits in the available address space
+ * in the crashdump map.
+ */
+
+/*
+ * Map some memory using the crashdump map.  'offset' is an offset in
+ * pages into the crashdump map to use for the start of the mapping.
+ */
+static void *
+table_map(vm_paddr_t pa, int offset, vm_offset_t length)
+{
+	vm_offset_t va, off;
+	void *data;
+
+	off = pa & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	pa = pa & PG_FRAME;
+	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
+	    (offset * PAGE_SIZE);
+	data = (void *)(va + off);
+	length -= PAGE_SIZE;
+	while (length > 0) {
+		va += PAGE_SIZE;
+		pa += PAGE_SIZE;
+		length -= PAGE_SIZE;
+		pmap_kenter(va, pa);
+		invlpg(va);
+	}
+	return (data);
+}
+
+/* Unmap memory previously mapped with table_map(). */
+static void
+table_unmap(void *data, vm_offset_t length)
+{
+	vm_offset_t va, off;
+
+	va = (vm_offset_t)data;
+	off = va & PAGE_MASK;
+	length = roundup(length + off, PAGE_SIZE);
+	va &= ~PAGE_MASK;
+	while (length > 0) {
+		pmap_kremove(va);
+		invlpg(va);
+		va += PAGE_SIZE;
+		length -= PAGE_SIZE;
+	}
+}
+
+/*
+ * Map a table at a given offset into the crashdump map.  It first
+ * maps the header to determine the table length and then maps the
+ * entire table.
+ */
+static void *
+map_table(vm_paddr_t pa, int offset, const char *sig)
+{
+	ACPI_TABLE_HEADER *header;
+	vm_offset_t length;
+	void *table;
+
+	header = table_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
+	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+		return (NULL);
+	}
+	length = header->Length;
+	table_unmap(header, sizeof(ACPI_TABLE_HEADER));
+	table = table_map(pa, offset, length);
+	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
+		if (bootverbose)
+			printf("ACPI: Failed checksum for table %s\n", sig);
+		table_unmap(table, length);
+		return (NULL);
+	}
+	return (table);
+}
+
+/*
+ * See if a given ACPI table is the requested table.  Returns the
+ * length of the able if it matches or zero on failure.
+ */
+static int
+probe_table(vm_paddr_t address, const char *sig)
+{
+	ACPI_TABLE_HEADER *table;
+
+	table = table_map(address, 0, sizeof(ACPI_TABLE_HEADER));
+	if (table == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map table at 0x%jx\n",
+			    (uintmax_t)address);
+		return (0);
+	}
+	if (bootverbose)
+		printf("Table '%.4s' at 0x%jx\n", table->Signature,
+		    (uintmax_t)address);
+
+	if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0) {
+		table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+		return (0);
+	}
+	table_unmap(table, sizeof(ACPI_TABLE_HEADER));
+	return (1);
+}
+
+/*
+ * Try to map a table at a given physical address previously returned
+ * by acpi_find_table().
+ */
+void *
+acpi_map_table(vm_paddr_t pa, const char *sig)
+{
+
+	return (map_table(pa, 0, sig));
+}
+
+/* Unmap a table previously mapped via acpi_map_table(). */
+void
+acpi_unmap_table(void *table)
+{
+	ACPI_TABLE_HEADER *header;
+
+	header = (ACPI_TABLE_HEADER *)table;
+	table_unmap(table, header->Length);
+}
+
+/*
+ * Return the physical address of the requested table or zero if one
+ * is not found.
+ */
+vm_paddr_t
+acpi_find_table(const char *sig)
+{
+	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_RSDT *rsdt;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *table;
+	vm_paddr_t addr;
+	int i, count;
+
+	if (resource_disabled("acpi", 0))
+		return (0);
+
+	/*
+	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
+	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
+	 * pmap_mapbios() to map the RSDP.
+	 */
+	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+		return (0);
+	rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP));
+	if (rsdp == NULL) {
+		if (bootverbose)
+			printf("ACPI: Failed to map RSDP\n");
+		return (0);
+	}
+
+	/*
+	 * For ACPI >= 2.0, use the XSDT if it is available.
+	 * Otherwise, use the RSDT.  We map the XSDT or RSDT at page 2
+	 * in the crashdump area.  Pages 0 and 1 are used to map in the
+	 * headers of candidate ACPI tables.
+	 */
+	addr = 0;
+	if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) {
+		/*
+		 * AcpiOsGetRootPointer only verifies the checksum for
+		 * the version 1.0 portion of the RSDP.  Version 2.0 has
+		 * an additional checksum that we verify first.
+		 */
+		if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) {
+			if (bootverbose)
+				printf("ACPI: RSDP failed extended checksum\n");
+			return (0);
+		}
+		xsdt = map_table(rsdp->XsdtPhysicalAddress, 2, ACPI_SIG_XSDT);
+		if (xsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map XSDT\n");
+			return (0);
+		}
+		count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT64);
+		for (i = 0; i < count; i++)
+			if (probe_table(xsdt->TableOffsetEntry[i], sig)) {
+				addr = xsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(xsdt);
+	} else {
+		rsdt = map_table(rsdp->RsdtPhysicalAddress, 2, ACPI_SIG_RSDT);
+		if (rsdt == NULL) {
+			if (bootverbose)
+				printf("ACPI: Failed to map RSDT\n");
+			return (0);
+		}
+		count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) /
+		    sizeof(UINT32);
+		for (i = 0; i < count; i++)
+			if (probe_table(rsdt->TableOffsetEntry[i], sig)) {
+				addr = rsdt->TableOffsetEntry[i];
+				break;
+			}
+		acpi_unmap_table(rsdt);
+	}
+	pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP));
+	if (addr == 0) {
+		if (bootverbose)
+			printf("ACPI: No %s table found\n", sig);
+		return (0);
+	}
+	if (bootverbose)
+		printf("%s: Found table at 0x%jx\n", sig, (uintmax_t)addr);
+
+	/*
+	 * Verify that we can map the full table and that its checksum is
+	 * correct, etc.
+	 */
+	table = map_table(addr, 0, sig);
+	if (table == NULL)
+		return (0);
+	acpi_unmap_table(table);
+
+	return (addr);
+}

Modified: stable/7/sys/i386/acpica/madt.c
==============================================================================
--- stable/7/sys/i386/acpica/madt.c	Thu Oct 29 17:14:18 2009	(r198617)
+++ stable/7/sys/i386/acpica/madt.c	Thu Oct 29 17:15:22 2009	(r198618)
@@ -36,25 +36,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
-#include 
 #include 
 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
+
 #include 
 #include 
 
-typedef	void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg);
-
 /* These two arrays are indexed by APIC IDs. */
 struct ioapic_info {
 	void *io_apic;
@@ -77,8 +71,6 @@ static enum intr_polarity interrupt_pola
 static enum intr_trigger interrupt_trigger(UINT16 IntiFlags, UINT8 Source);
 static int	madt_find_cpu(u_int acpi_id, u_int *apic_id);
 static int	madt_find_interrupt(int intr, void **apic, u_int *pin);
-static void	*madt_map(vm_paddr_t pa, int offset, vm_offset_t length);
-static void	*madt_map_table(vm_paddr_t pa, int offset, const char *sig);
 static void	madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg);
 static void	madt_parse_interrupt_override(
 		    ACPI_MADT_INTERRUPT_OVERRIDE *intr);
@@ -90,13 +82,10 @@ static int	madt_probe(void);
 static int	madt_probe_cpus(void);
 static void	madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
 		    void *arg __unused);
-static int	madt_probe_table(vm_paddr_t address);
 static void	madt_register(void *dummy);
 static int	madt_setup_local(void);
 static int	madt_setup_io(void);
-static void	madt_unmap(void *data, vm_offset_t length);
-static void	madt_unmap_table(void *table);
-static void	madt_walk_table(madt_entry_handler *handler, void *arg);
+static void	madt_walk_table(acpi_subtable_handler *handler, void *arg);
 
 static struct apic_enumerator madt_enumerator = {
 	"MADT",
@@ -106,87 +95,6 @@ static struct apic_enumerator madt_enume
 	madt_setup_io
 };
 
-/*
- * Code to abuse the crashdump map to map in the tables for the early
- * probe.  We cheat and make the following assumptions about how we
- * use this KVA: pages 0 and 1 are used to map in the header of each
- * table found via the RSDT or XSDT and pages 2 to n are used to map
- * in the RSDT or XSDT.  We have to use 2 pages for the table headers
- * in case a header spans a page boundary.  The offset is in pages;
- * the length is in bytes.
- */
-static void *
-madt_map(vm_paddr_t pa, int offset, vm_offset_t length)
-{
-	vm_offset_t va, off;
-	void *data;
-
-	off = pa & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	pa = pa & PG_FRAME;
-	va = (vm_offset_t)pmap_kenter_temporary(pa, offset) +
-	    (offset * PAGE_SIZE);
-	data = (void *)(va + off);
-	length -= PAGE_SIZE;
-	while (length > 0) {
-		va += PAGE_SIZE;
-		pa += PAGE_SIZE;
-		length -= PAGE_SIZE;
-		pmap_kenter(va, pa);
-		invlpg(va);
-	}
-	return (data);
-}
-
-static void
-madt_unmap(void *data, vm_offset_t length)
-{
-	vm_offset_t va, off;
-
-	va = (vm_offset_t)data;
-	off = va & PAGE_MASK;
-	length = roundup(length + off, PAGE_SIZE);
-	va &= ~PAGE_MASK;
-	while (length > 0) {
-		pmap_kremove(va);
-		invlpg(va);
-		va += PAGE_SIZE;
-		length -= PAGE_SIZE;
-	}
-}
-
-static void *
-madt_map_table(vm_paddr_t pa, int offset, const char *sig)
-{
-	ACPI_TABLE_HEADER *header;
-	vm_offset_t length;
-	void *table;
-
-	header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
-	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
-		madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-		return (NULL);
-	}
-	length = header->Length;
-	madt_unmap(header, sizeof(ACPI_TABLE_HEADER));
-	table = madt_map(pa, offset, length);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 21:13:57 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 96AFA106566B;
	Thu, 29 Oct 2009 21:13:57 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8504C8FC2E;
	Thu, 29 Oct 2009 21:13:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TLDvwu009723;
	Thu, 29 Oct 2009 21:13:57 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TLDvJ1009721;
	Thu, 29 Oct 2009 21:13:57 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <200910292113.n9TLDvJ1009721@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Thu, 29 Oct 2009 21:13:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198624 - stable/8/bin/sh
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 21:13:57 -0000

Author: jilles
Date: Thu Oct 29 21:13:57 2009
New Revision: 198624
URL: http://svn.freebsd.org/changeset/base/198624

Log:
  MFC r197371: Mention that NUL characters are not allowed in sh(1) input.
  
  I do not consider this a bug because POSIX permits it and argument strings
  and environment variables cannot contain '\0' anyway.
  
  PR:		bin/25542

Modified:
  stable/8/bin/sh/   (props changed)
  stable/8/bin/sh/sh.1

Modified: stable/8/bin/sh/sh.1
==============================================================================
--- stable/8/bin/sh/sh.1	Thu Oct 29 20:53:26 2009	(r198623)
+++ stable/8/bin/sh/sh.1	Thu Oct 29 21:13:57 2009	(r198624)
@@ -375,6 +375,10 @@ introduces a comment if used at the begi
 The word starting with
 .Ql #
 and the rest of the line are ignored.
+.Pp
+.Tn ASCII
+.Dv NUL
+characters (character code 0) are not allowed in shell input.
 .Ss Quoting
 Quoting is used to remove the special meaning of certain characters
 or words to the shell, such as operators, whitespace, keywords,

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 21:25:16 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 718DC106568D;
	Thu, 29 Oct 2009 21:25:16 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5FFB08FC16;
	Thu, 29 Oct 2009 21:25:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TLPGBh010441;
	Thu, 29 Oct 2009 21:25:16 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TLPGGY010439;
	Thu, 29 Oct 2009 21:25:16 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <200910292125.n9TLPGGY010439@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Thu, 29 Oct 2009 21:25:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198628 - stable/8/usr.bin/find
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 21:25:16 -0000

Author: jilles
Date: Thu Oct 29 21:25:16 2009
New Revision: 198628
URL: http://svn.freebsd.org/changeset/base/198628

Log:
  MFC r197363: Update find(1) man page for -L/-delete interaction.
  
  It is a bit unfortunate that the example to delete broken symlinks now uses
  rm(1), but allowing this with -delete would require fixing fts(3) to not
  imply FTS_NOCHDIR if FTS_LOGICAL is given (or hacks in the -delete option).
  
  PR:		bin/90687

Modified:
  stable/8/usr.bin/find/   (props changed)
  stable/8/usr.bin/find/find.1

Modified: stable/8/usr.bin/find/find.1
==============================================================================
--- stable/8/usr.bin/find/find.1	Thu Oct 29 21:23:44 2009	(r198627)
+++ stable/8/usr.bin/find/find.1	Thu Oct 29 21:25:16 2009	(r198628)
@@ -312,6 +312,7 @@ character in its pathname relative to
 .Dq Pa \&.
 for security reasons.
 Depth-first traversal processing is implied by this option.
+Following symlinks is incompatible with this option.
 .It Ic -depth
 Always true;
 same as the
@@ -920,7 +921,7 @@ recent than the current time minus one m
 Use the
 .Xr echo 1
 command to print out a list of all the files.
-.It Li "find -L /usr/ports/packages -type l -delete"
+.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +"
 Delete all broken symbolic links in
 .Pa /usr/ports/packages .
 .It Li "find /usr/src -name CVS -prune -o -depth +6 -print"

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:09:03 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0925D1065670;
	Thu, 29 Oct 2009 23:09:03 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E87348FC15;
	Thu, 29 Oct 2009 23:09:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TN92U4013618;
	Thu, 29 Oct 2009 23:09:02 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TN92NC013616;
	Thu, 29 Oct 2009 23:09:02 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292309.n9TN92NC013616@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:09:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198630 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:09:03 -0000

Author: thompsa
Date: Thu Oct 29 23:09:02 2009
New Revision: 198630
URL: http://svn.freebsd.org/changeset/base/198630

Log:
  MFC r196488
  
   - allow disabling "root_mount_hold()" by setting a sysctl/tunable at boot
   - remove some redundant initial explore code

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/controller/usb_controller.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/controller/usb_controller.c
==============================================================================
--- stable/8/sys/dev/usb/controller/usb_controller.c	Thu Oct 29 21:30:21 2009	(r198629)
+++ stable/8/sys/dev/usb/controller/usb_controller.c	Thu Oct 29 23:09:02 2009	(r198630)
@@ -67,7 +67,6 @@ static device_attach_t usb_attach;
 static device_detach_t usb_detach;
 
 static void	usb_attach_sub(device_t, struct usb_bus *);
-static void	usb_post_init(void *);
 
 /* static variables */
 
@@ -84,8 +83,6 @@ TUNABLE_INT("hw.usb.no_boot_wait", &usb_
 SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0,
     "No device enumerate waiting at boot.");
 
-static uint8_t usb_post_init_called = 0;
-
 static devclass_t usb_devclass;
 
 static device_method_t usb_methods[] = {
@@ -142,12 +139,8 @@ usb_attach(device_t dev)
 		bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
 	}
 
-	if (usb_post_init_called) {
-		mtx_lock(&Giant);
-		usb_attach_sub(dev, bus);
-		mtx_unlock(&Giant);
-		usb_needs_explore(bus, 1);
-	}
+	usb_attach_sub(dev, bus);
+
 	return (0);			/* return success */
 }
 
@@ -226,22 +219,24 @@ usb_bus_explore(struct usb_proc_msg *pm)
 			/* avoid zero, hence that is memory default */
 			bus->driver_added_refcount = 1;
 		}
-		USB_BUS_UNLOCK(bus);
 
-		mtx_lock(&Giant);
+		/*
+		 * The following three lines of code are only here to
+		 * recover from DDB:
+		 */
+		usb_proc_rewakeup(&bus->control_xfer_proc);
+		usb_proc_rewakeup(&bus->giant_callback_proc);
+		usb_proc_rewakeup(&bus->non_giant_callback_proc);
+
+		USB_BUS_UNLOCK(bus);
 
 		/*
 		 * First update the USB power state!
 		 */
 		usb_bus_powerd(bus);
-		/*
-		 * Explore the Root USB HUB. This call can sleep,
-		 * exiting Giant, which is actually Giant.
-		 */
-		(udev->hub->explore) (udev);
-
-		mtx_unlock(&Giant);
 
+		 /* Explore the Root USB HUB. */
+		(udev->hub->explore) (udev);
 		USB_BUS_LOCK(bus);
 	}
 	if (bus->bus_roothold != NULL) {
@@ -269,10 +264,10 @@ usb_bus_detach(struct usb_proc_msg *pm)
 	device_set_softc(dev, NULL);
 	USB_BUS_UNLOCK(bus);
 
-	mtx_lock(&Giant);
-
 	/* detach children first */
+	mtx_lock(&Giant);
 	bus_generic_detach(dev);
+	mtx_unlock(&Giant);
 
 	/*
 	 * Free USB Root device, but not any sub-devices, hence they
@@ -281,7 +276,6 @@ usb_bus_detach(struct usb_proc_msg *pm)
 	usb_free_device(udev,
 	    USB_UNCFG_FLAG_FREE_EP0);
 
-	mtx_unlock(&Giant);
 	USB_BUS_LOCK(bus);
 	/* clear bdev variable last */
 	bus->bdev = NULL;
@@ -297,6 +291,12 @@ usb_power_wdog(void *arg)
 	usb_callout_reset(&bus->power_wdog,
 	    4 * hz, usb_power_wdog, arg);
 
+	/*
+	 * The following line of code is only here to recover from
+	 * DDB:
+	 */
+	usb_proc_rewakeup(&bus->explore_proc);	/* recover from DDB */
+
 	USB_BUS_UNLOCK(bus);
 
 	usb_bus_power_update(bus);
@@ -350,7 +350,6 @@ usb_bus_attach(struct usb_proc_msg *pm)
 	}
 
 	USB_BUS_UNLOCK(bus);
-	mtx_lock(&Giant);		/* XXX not required by USB */
 
 	/* default power_mask value */
 	bus->hw_power_state =
@@ -383,7 +382,6 @@ usb_bus_attach(struct usb_proc_msg *pm)
 		err = USB_ERR_NOMEM;
 	}
 
-	mtx_unlock(&Giant);
 	USB_BUS_LOCK(bus);
 
 	if (err) {
@@ -401,17 +399,18 @@ usb_bus_attach(struct usb_proc_msg *pm)
 /*------------------------------------------------------------------------*
  *	usb_attach_sub
  *
- * This function creates a thread which runs the USB attach code. It
- * is factored out, hence it can be called at two different places in
- * time. During bootup this function is called from
- * "usb_post_init". During hot-plug it is called directly from the
- * "usb_attach()" method.
+ * This function creates a thread which runs the USB attach code.
  *------------------------------------------------------------------------*/
 static void
 usb_attach_sub(device_t dev, struct usb_bus *bus)
 {
 	const char *pname = device_get_nameunit(dev);
 
+	mtx_lock(&Giant);
+	if (usb_devclass_ptr == NULL)
+		usb_devclass_ptr = devclass_find("usbus");
+	mtx_unlock(&Giant);
+
 	/* Initialise USB process messages */
 	bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore;
 	bus->explore_msg[0].bus = bus;
@@ -454,55 +453,12 @@ usb_attach_sub(device_t dev, struct usb_
 			/* ignore */
 		}
 		USB_BUS_UNLOCK(bus);
-	}
-}
-
-/*------------------------------------------------------------------------*
- *	usb_post_init
- *
- * This function is called to attach all USB busses that were found
- * during bootup.
- *------------------------------------------------------------------------*/
-static void
-usb_post_init(void *arg)
-{
-	struct usb_bus *bus;
-	devclass_t dc;
-	device_t dev;
-	int max;
-	int n;
 
-	mtx_lock(&Giant);
-
-	usb_devclass_ptr = devclass_find("usbus");
-
-	dc = usb_devclass_ptr;
-	if (dc) {
-		max = devclass_get_maxunit(dc) + 1;
-		for (n = 0; n != max; n++) {
-			dev = devclass_get_device(dc, n);
-			if (dev && device_is_attached(dev)) {
-				bus = device_get_ivars(dev);
-				if (bus) {
-					mtx_lock(&Giant);
-					usb_attach_sub(dev, bus);
-					mtx_unlock(&Giant);
-				}
-			}
-		}
-	} else {
-		DPRINTFN(0, "no devclass\n");
+		/* Do initial explore */
+		usb_needs_explore(bus, 1);
 	}
-	usb_post_init_called = 1;
-
-	/* explore all USB busses in parallell */
-
-	usb_needs_explore_all();
-
-	mtx_unlock(&Giant);
 }
 
-SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL);
 SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL);
 
 /*------------------------------------------------------------------------*

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:09:38 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 75EE510656A7;
	Thu, 29 Oct 2009 23:09:38 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 484308FC23;
	Thu, 29 Oct 2009 23:09:38 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TN9c1U013676;
	Thu, 29 Oct 2009 23:09:38 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TN9cCW013673;
	Thu, 29 Oct 2009 23:09:38 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292309.n9TN9cCW013673@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:09:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198631 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/misc dev/usb/storage dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:09:38 -0000

Author: thompsa
Date: Thu Oct 29 23:09:37 2009
New Revision: 198631
URL: http://svn.freebsd.org/changeset/base/198631

Log:
  MFC r196490
  
   - FIFO's are always opened separately in read and write direction even if the
     actual device is opened for read and write. Fix fflags check so that the UFM
     and URIO drivers work.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/misc/ufm.c
  stable/8/sys/dev/usb/storage/urio.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/misc/ufm.c
==============================================================================
--- stable/8/sys/dev/usb/misc/ufm.c	Thu Oct 29 23:09:02 2009	(r198630)
+++ stable/8/sys/dev/usb/misc/ufm.c	Thu Oct 29 23:09:37 2009	(r198631)
@@ -86,11 +86,9 @@ static device_attach_t ufm_attach;
 static device_detach_t ufm_detach;
 
 static usb_fifo_ioctl_t ufm_ioctl;
-static usb_fifo_open_t ufm_open;
 
 static struct usb_fifo_methods ufm_fifo_methods = {
 	.f_ioctl = &ufm_ioctl,
-	.f_open = &ufm_open,
 	.basename[0] = "ufm",
 };
 
@@ -179,15 +177,6 @@ ufm_detach(device_t dev)
 }
 
 static int
-ufm_open(struct usb_fifo *dev, int fflags)
-{
-	if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
-		return (EACCES);
-	}
-	return (0);
-}
-
-static int
 ufm_do_req(struct ufm_softc *sc, uint8_t request,
     uint16_t value, uint16_t index, uint8_t *retbuf)
 {
@@ -315,6 +304,10 @@ ufm_ioctl(struct usb_fifo *fifo, u_long 
 	struct ufm_softc *sc = usb_fifo_softc(fifo);
 	int error = 0;
 
+	if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
+		return (EACCES);
+	}
+
 	switch (cmd) {
 	case FM_SET_FREQ:
 		error = ufm_set_freq(sc, addr);

Modified: stable/8/sys/dev/usb/storage/urio.c
==============================================================================
--- stable/8/sys/dev/usb/storage/urio.c	Thu Oct 29 23:09:02 2009	(r198630)
+++ stable/8/sys/dev/usb/storage/urio.c	Thu Oct 29 23:09:37 2009	(r198631)
@@ -390,9 +390,6 @@ urio_open(struct usb_fifo *fifo, int ffl
 {
 	struct urio_softc *sc = usb_fifo_softc(fifo);
 
-	if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
-		return (EACCES);
-	}
 	if (fflags & FREAD) {
 		/* clear stall first */
 		mtx_lock(&sc->sc_mtx);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:10:12 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 076AD106566C;
	Thu, 29 Oct 2009 23:10:12 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E74358FC19;
	Thu, 29 Oct 2009 23:10:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNABeB013747;
	Thu, 29 Oct 2009 23:10:11 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNABh3013745;
	Thu, 29 Oct 2009 23:10:11 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292310.n9TNABh3013745@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:10:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198632 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:10:12 -0000

Author: thompsa
Date: Thu Oct 29 23:10:11 2009
New Revision: 198632
URL: http://svn.freebsd.org/changeset/base/198632

Log:
  MFC r196491
  
   We used force all of the GPIO pins low first and then
   enable the ones we want. This has been changed to better
   match the ADMtek's reference design to avoid setting the
   power-down configuration line of the PHY at the same time
   it is reset.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_aue.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_aue.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_aue.c	Thu Oct 29 23:09:37 2009	(r198631)
+++ stable/8/sys/dev/usb/net/if_aue.c	Thu Oct 29 23:10:11 2009	(r198632)
@@ -484,7 +484,7 @@ aue_miibus_writereg(device_t dev, int ph
 	}
 
 	if (i == AUE_TIMEOUT)
-		device_printf(sc->sc_ue.ue_dev, "MII read timed out\n");
+		device_printf(sc->sc_ue.ue_dev, "MII write timed out\n");
 
 	if (!locked)
 		AUE_UNLOCK(sc);
@@ -603,11 +603,14 @@ aue_reset(struct aue_softc *sc)
 	 * to set the GPIO pins high so that the PHY(s) will
 	 * be enabled.
 	 *
-	 * Note: We force all of the GPIO pins low first, *then*
-	 * enable the ones we want.
+	 * NOTE: We used to force all of the GPIO pins low first and then
+	 * enable the ones we want. This has been changed to better
+	 * match the ADMtek's reference design to avoid setting the
+	 * power-down configuration line of the PHY at the same time
+	 * it is reset.
 	 */
-	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0);
-	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0|AUE_GPIO_SEL1);
+	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_SEL0|AUE_GPIO_SEL1);
+	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_SEL0|AUE_GPIO_SEL1|AUE_GPIO_OUT0);
 
 	if (sc->sc_flags & AUE_FLAG_LSYS) {
 		/* Grrr. LinkSys has to be different from everyone else. */

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:10:42 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 44237106568B;
	Thu, 29 Oct 2009 23:10:42 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2F94E8FC21;
	Thu, 29 Oct 2009 23:10:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNAgqn013806;
	Thu, 29 Oct 2009 23:10:42 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNAgT6013804;
	Thu, 29 Oct 2009 23:10:42 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292310.n9TNAgT6013804@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:10:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198633 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:10:42 -0000

Author: thompsa
Date: Thu Oct 29 23:10:41 2009
New Revision: 198633
URL: http://svn.freebsd.org/changeset/base/198633

Log:
  MFC r196492
  
   - fix CDC ethernet matching order so that the match flags get correct.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_cdce.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_cdce.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:10:11 2009	(r198632)
+++ stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:10:41 2009	(r198633)
@@ -197,9 +197,6 @@ static const struct usb_ether_methods cd
 };
 
 static const struct usb_device_id cdce_devs[] = {
-	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)},
-	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
-
 	{USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, CDCE_FLAG_NO_UNION)},
 	{USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, CDCE_FLAG_NO_UNION)},
 	{USB_VPI(USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX, CDCE_FLAG_NO_UNION)},
@@ -213,6 +210,9 @@ static const struct usb_device_id cdce_d
 	{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLA300, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
 	{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC700, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
 	{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC750, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
+
+	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)},
+	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
 };
 
 static int

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:11:14 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 471381065679;
	Thu, 29 Oct 2009 23:11:14 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 329678FC21;
	Thu, 29 Oct 2009 23:11:14 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNBEK0013883;
	Thu, 29 Oct 2009 23:11:14 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNBEMd013880;
	Thu, 29 Oct 2009 23:11:14 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292311.n9TNBEMd013880@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:11:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198634 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:11:14 -0000

Author: thompsa
Date: Thu Oct 29 23:11:13 2009
New Revision: 198634
URL: http://svn.freebsd.org/changeset/base/198634

Log:
  MFC r196493
  
   - Fix false positive uipaq probe

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/uipaq.c
  stable/8/sys/dev/usb/usb.h
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/uipaq.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uipaq.c	Thu Oct 29 23:10:41 2009	(r198633)
+++ stable/8/sys/dev/usb/serial/uipaq.c	Thu Oct 29 23:11:13 2009	(r198634)
@@ -1103,6 +1103,10 @@ uipaq_probe(device_t dev)
 	if (uaa->info.bIfaceIndex != UIPAQ_IFACE_INDEX) {
 		return (ENXIO);
 	}
+	if (uaa->info.bInterfaceClass == UICLASS_IAD) {
+		DPRINTF("IAD detected - not UIPAQ serial device\n");
+		return (ENXIO);
+	}
 	return (usbd_lookup_id_by_uaa(uipaq_devs, sizeof(uipaq_devs), uaa));
 }
 

Modified: stable/8/sys/dev/usb/usb.h
==============================================================================
--- stable/8/sys/dev/usb/usb.h	Thu Oct 29 23:10:41 2009	(r198633)
+++ stable/8/sys/dev/usb/usb.h	Thu Oct 29 23:11:13 2009	(r198634)
@@ -484,6 +484,8 @@ typedef struct usb_interface_assoc_descr
 #define	UISUBCLASS_RF			0x01
 #define	UIPROTO_BLUETOOTH		0x01
 
+#define	UICLASS_IAD		0xEF	/* Interface Association Descriptor */
+
 #define	UICLASS_APPL_SPEC	0xfe
 #define	UISUBCLASS_FIRMWARE_DOWNLOAD	1
 #define	UISUBCLASS_IRDA			2

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:11:48 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6395E106568D;
	Thu, 29 Oct 2009 23:11:48 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4F0128FC22;
	Thu, 29 Oct 2009 23:11:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNBmI8013940;
	Thu, 29 Oct 2009 23:11:48 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNBmEb013938;
	Thu, 29 Oct 2009 23:11:48 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292311.n9TNBmEb013938@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:11:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198635 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:11:48 -0000

Author: thompsa
Date: Thu Oct 29 23:11:48 2009
New Revision: 198635
URL: http://svn.freebsd.org/changeset/base/198635

Log:
  MFC r196494
  
   - fix uvisor support, mostly correct buffer sizes used.
   - correct device info flag for SONY Cli NR70V

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/uvisor.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/uvisor.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uvisor.c	Thu Oct 29 23:11:13 2009	(r198634)
+++ stable/8/sys/dev/usb/serial/uvisor.c	Thu Oct 29 23:11:48 2009	(r198635)
@@ -95,7 +95,15 @@ SYSCTL_INT(_hw_usb_uvisor, OID_AUTO, deb
 
 #define	UVISOR_CONFIG_INDEX	0
 #define	UVISOR_IFACE_INDEX	0
-#define	UVISOR_BUFSIZE       1024	/* bytes */
+
+/*
+ * The following buffer sizes are hardcoded due to the way the Palm
+ * firmware works. It looks like the device is not short terminating
+ * the data transferred.
+ */
+#define	UVISORIBUFSIZE	       0	/* Use wMaxPacketSize */
+#define	UVISOROBUFSIZE	       32	/* bytes */
+#define	UVISOROFRAMES	       32	/* units */
 
 /* From the Linux driver */
 /*
@@ -208,7 +216,8 @@ static const struct usb_config uvisor_co
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
-		.bufsize = UVISOR_BUFSIZE,	/* bytes */
+		.bufsize = UVISOROBUFSIZE * UVISOROFRAMES,
+		.frames = UVISOROFRAMES,
 		.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
 		.callback = &uvisor_write_callback,
 	},
@@ -217,7 +226,7 @@ static const struct usb_config uvisor_co
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
-		.bufsize = UVISOR_BUFSIZE,	/* bytes */
+		.bufsize = UVISORIBUFSIZE,
 		.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
 		.callback = &uvisor_read_callback,
 	},
@@ -270,7 +279,7 @@ static const struct usb_device_id uvisor
 	{USB_VPI(USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE31, UVISOR_FLAG_PALM4)},
 	{USB_VPI(USB_VENDOR_SAMSUNG, USB_PRODUCT_SAMSUNG_I500, UVISOR_FLAG_PALM4)},
 	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40, 0)},
-	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41, UVISOR_FLAG_PALM4)},
+	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41, 0)},
 	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_S360, UVISOR_FLAG_PALM4)},
 	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_NX60, UVISOR_FLAG_PALM4)},
 	{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_35, UVISOR_FLAG_PALM35)},
@@ -375,7 +384,6 @@ uvisor_init(struct uvisor_softc *sc, str
 	struct uvisor_connection_info coninfo;
 	struct uvisor_palm_connection_info pconinfo;
 	uint16_t actlen;
-	uWord wAvail;
 	uint8_t buffer[256];
 
 	if (sc->sc_flag & UVISOR_FLAG_VISOR) {
@@ -496,6 +504,9 @@ uvisor_init(struct uvisor_softc *sc, str
 			goto done;
 		}
 	}
+#if 0
+	uWord wAvail;
+
 	DPRINTF("getting available bytes\n");
 	req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
 	req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE;
@@ -507,6 +518,7 @@ uvisor_init(struct uvisor_softc *sc, str
 		goto done;
 	}
 	DPRINTF("avail=%d\n", UGETW(wAvail));
+#endif
 
 	DPRINTF("done\n");
 done:
@@ -579,19 +591,31 @@ uvisor_write_callback(struct usb_xfer *x
 	struct uvisor_softc *sc = usbd_xfer_softc(xfer);
 	struct usb_page_cache *pc;
 	uint32_t actlen;
+	uint8_t x;
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_SETUP:
 	case USB_ST_TRANSFERRED:
 tr_setup:
-		pc = usbd_xfer_get_frame(xfer, 0);
-		if (ucom_get_data(&sc->sc_ucom, pc, 0,
-		    UVISOR_BUFSIZE, &actlen)) {
+		for (x = 0; x != UVISOROFRAMES; x++) {
+
+			usbd_xfer_set_frame_offset(xfer, 
+			    x * UVISOROBUFSIZE, x);
 
-			usbd_xfer_set_frame_len(xfer, 0, actlen);
+			pc = usbd_xfer_get_frame(xfer, x);
+			if (ucom_get_data(&sc->sc_ucom, pc, 0,
+			    UVISOROBUFSIZE, &actlen)) {
+				usbd_xfer_set_frame_len(xfer, x, actlen);
+			} else {
+				break;
+			}
+		}
+		/* check for data */
+		if (x != 0) {
+			usbd_xfer_set_frames(xfer, x);
 			usbd_transfer_submit(xfer);
 		}
-		return;
+		break;
 
 	default:			/* Error */
 		if (error != USB_ERR_CANCELLED) {
@@ -599,7 +623,7 @@ tr_setup:
 			usbd_xfer_set_stall(xfer);
 			goto tr_setup;
 		}
-		return;
+		break;
 	}
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:12:30 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6AA2F1065695;
	Thu, 29 Oct 2009 23:12:30 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 561158FC0C;
	Thu, 29 Oct 2009 23:12:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNCUF1014008;
	Thu, 29 Oct 2009 23:12:30 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNCUPY014005;
	Thu, 29 Oct 2009 23:12:30 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292312.n9TNCUPY014005@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:12:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198636 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/usb/storage dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:12:30 -0000

Author: thompsa
Date: Thu Oct 29 23:12:29 2009
New Revision: 198636
URL: http://svn.freebsd.org/changeset/base/198636

Log:
  MFC r196495
  
   Add mass storage quirks.
  
  PR:             usb/137138,usb/137226,usb/137789,usb/135372

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/storage/umass.c
  stable/8/sys/dev/usb/usbdevs
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/storage/umass.c
==============================================================================
--- stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:11:48 2009	(r198635)
+++ stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:12:29 2009	(r198636)
@@ -412,6 +412,10 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_DEFAULT,
 		NO_SYNCHRONIZE_CACHE
 	},
+	{USB_VENDOR_ALCOR, USB_PRODUCT_ALCOR_SDCR_6335, RID_WILDCARD,
+		UMASS_PROTO_DEFAULT,
+		NO_TEST_UNIT_READY | NO_SYNCHRONIZE_CACHE
+	},
 	{USB_VENDOR_ALCOR, USB_PRODUCT_ALCOR_AU6390, RID_WILDCARD,
 		UMASS_PROTO_DEFAULT,
 		NO_SYNCHRONIZE_CACHE
@@ -733,6 +737,10 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_UFI,
 		NO_QUIRKS
 	},
+	{ USB_VENDOR_PHILIPS, USB_PRODUCT_PHILIPS_SPE3030CC, RID_WILDCARD,
+		UMASS_PROTO_DEFAULT,
+		NO_SYNCHRONIZE_CACHE
+	},
 	{USB_VENDOR_PLEXTOR, USB_PRODUCT_PLEXTOR_40_12_40U, RID_WILDCARD,
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_TEST_UNIT_READY
@@ -893,6 +901,10 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_UFI | UMASS_PROTO_CBI,
 		NO_QUIRKS
 	},
+	{USB_VENDOR_TECLAST, USB_PRODUCT_TECLAST_TLC300, RID_WILDCARD,
+		UMASS_PROTO_DEFAULT,
+		NO_TEST_UNIT_READY | NO_SYNCHRONIZE_CACHE
+	},
 	{USB_VENDOR_TREK, USB_PRODUCT_TREK_MEMKEY, RID_WILDCARD,
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_INQUIRY
@@ -965,6 +977,10 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_SYNCHRONIZE_CACHE
 	},
+	{USB_VENDOR_ASUS, USB_PRODUCT_ASUS_GMSC, RID_WILDCARD,
+		UMASS_PROTO_DEFAULT,
+		NO_SYNCHRONIZE_CACHE
+	},
 	{VID_EOT, PID_EOT, RID_EOT, 0, 0}
 };
 

Modified: stable/8/sys/dev/usb/usbdevs
==============================================================================
--- stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:11:48 2009	(r198635)
+++ stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:12:29 2009	(r198636)
@@ -360,6 +360,7 @@ vendor SMC		0x0707	Standard Microsystems
 vendor PUTERCOM		0x0708	Putercom
 vendor MCT		0x0711	MCT
 vendor IMATION		0x0718	Imation
+vendor TECLAST		0x071b	Teclast
 vendor SONYERICSSON	0x0731	Sony Ericsson
 vendor EICON		0x0734	Eicon Networks
 vendor SYNTECH		0x0745	Syntech Information
@@ -585,6 +586,7 @@ vendor NETGEAR3		0x1385	Netgear
 vendor BALTECH		0x13ad	Baltech
 vendor CISCOLINKSYS	0x13b1	Cisco-Linksys
 vendor SHARK		0x13d2	Shark
+vendor EMTEC		0x13fe	Emtec
 vendor NOVATEL		0x1410	Novatel Wireless
 vendor MERLIN		0x1416	Merlin
 vendor WISTRONNEWEB	0x1435	Wistron NeWeb
@@ -820,6 +822,7 @@ product AKS USBHASP		0x0001	USB-HASP 0.0
 /* Alcor Micro, Inc. products */
 product ALCOR2 KBD_HUB		0x2802	Kbd Hub
 
+product ALCOR SDCR_6335		0x6335	SD/MMC Card Reader
 product ALCOR TRANSCEND		0x6387	Transcend JetFlash Drive
 product ALCOR MA_KBD_HUB	0x9213	MacAlly Kbd Hub
 product ALCOR AU9814		0x9215	AU9814 Hub
@@ -861,6 +864,12 @@ product APC UPS			0x0002	Uninterruptible
 
 /* Apple Computer products */
 product APPLE EXT_KBD		0x020c	Apple Extended USB Keyboard
+product APPLE KBD_TP_ANSI	0x0223	Apple Internal Keyboard/Trackpad (Wellspring/ANSI)
+product APPLE KBD_TP_ISO	0x0224	Apple Internal Keyboard/Trackpad (Wellspring/ISO)
+product APPLE KBD_TP_JIS	0x0225	Apple Internal Keyboard/Trackpad (Wellspring/JIS)
+product APPLE KBD_TP_ANSI2	0x0230	Apple Internal Keyboard/Trackpad (Wellspring2/ANSI)
+product APPLE KBD_TP_ISO2	0x0231	Apple Internal Keyboard/Trackpad (Wellspring2/ISO)
+product APPLE KBD_TP_JIS2	0x0232	Apple Internal Keyboard/Trackpad (Wellspring2/JIS)
 product APPLE OPTMOUSE		0x0302	Optical mouse
 product APPLE MIGHTYMOUSE	0x0304	Mighty Mouse
 product APPLE EXT_KBD_HUB	0x1003	Hub in Apple Extended USB Keyboard
@@ -902,6 +911,7 @@ product ASUS RT2573_1		0x1723	RT2573
 product ASUS RT2573_2		0x1724	RT2573
 product ASUS LCM		0x1726	LCM display
 product ASUS P535		0x420f	ASUS P535 PDA
+product	ASUS GMSC		0x422f	ASUS Generic Mass Storage
 
 /* ATen products */
 product ATEN UC1284		0x2001	Parallel printer
@@ -1971,6 +1981,7 @@ product PHILIPS HUB		0x0201	hub
 product PHILIPS PCA646VC	0x0303	PCA646VC PC Camera
 product PHILIPS PCVC680K	0x0308	PCVC680K Vesta Pro PC Camera
 product PHILIPS DSS150		0x0471	DSS 150 Digital Speaker System
+product PHILIPS SPE3030CC	0x083a	USB 2.0 External Disk
 product PHILIPS SNU5600		0x1236	SNU5600
 product PHILIPS UM10016		0x1552	ISP 1581 Hi-Speed USB MPEG2 Encoder Reference Kit
 product PHILIPS DIVAUSB		0x1801	DIVA USB mp3 player
@@ -2345,6 +2356,9 @@ product SUN KBD_HUB		0x100e	Kbd Hub
 /* Super Top products */
 product	SUPERTOP IDE		0x6600	USB-IDE
 
+/* Teclast products */
+product TECLAST TLC300		0x3203	USB Media Player
+
 /* Supra products */
 product DIAMOND2 SUPRAEXPRESS56K 0x07da	Supra Express 56K modem
 product DIAMOND2 SUPRA2890	0x0b4a	SupraMax 2890 56K Modem

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:13:03 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 56979106568B;
	Thu, 29 Oct 2009 23:13:03 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 425738FC20;
	Thu, 29 Oct 2009 23:13:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TND3Ce014072;
	Thu, 29 Oct 2009 23:13:03 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TND3AE014070;
	Thu, 29 Oct 2009 23:13:03 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292313.n9TND3AE014070@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:13:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198637 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:13:03 -0000

Author: thompsa
Date: Thu Oct 29 23:13:02 2009
New Revision: 198637
URL: http://svn.freebsd.org/changeset/base/198637

Log:
  MFC r196496
  
   Add a reminder comment to optimize bus_dmamap_sync calls.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usb_busdma.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usb_busdma.c
==============================================================================
--- stable/8/sys/dev/usb/usb_busdma.c	Thu Oct 29 23:12:29 2009	(r198636)
+++ stable/8/sys/dev/usb/usb_busdma.c	Thu Oct 29 23:13:02 2009	(r198637)
@@ -679,6 +679,12 @@ usb_pc_cpu_invalidate(struct usb_page_ca
 		/* nothing has been loaded into this page cache! */
 		return;
 	}
+
+	/*
+	 * TODO: We currently do XXX_POSTREAD and XXX_PREREAD at the
+	 * same time, but in the future we should try to isolate the
+	 * different cases to optimise the code. --HPS
+	 */
 	bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_POSTREAD);
 	bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_PREREAD);
 }

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:13:36 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8F45F106568F;
	Thu, 29 Oct 2009 23:13:36 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7B2D58FC27;
	Thu, 29 Oct 2009 23:13:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNDag5014132;
	Thu, 29 Oct 2009 23:13:36 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNDaB0014130;
	Thu, 29 Oct 2009 23:13:36 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292313.n9TNDaB0014130@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:13:36 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198638 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/wlan dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:13:36 -0000

Author: thompsa
Date: Thu Oct 29 23:13:36 2009
New Revision: 198638
URL: http://svn.freebsd.org/changeset/base/198638

Log:
  MFC r196497
  
   Remove redundant locking.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/wlan/if_upgt.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/wlan/if_upgt.c
==============================================================================
--- stable/8/sys/dev/usb/wlan/if_upgt.c	Thu Oct 29 23:13:02 2009	(r198637)
+++ stable/8/sys/dev/usb/wlan/if_upgt.c	Thu Oct 29 23:13:36 2009	(r198638)
@@ -465,7 +465,6 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd
 
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-		mtx_lock(&Giant);
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				if ((ifp->if_flags ^ sc->sc_if_flags) &
@@ -482,7 +481,6 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd
 		sc->sc_if_flags = ifp->if_flags;
 		if (startall)
 			ieee80211_start_all(ic);
-		mtx_unlock(&Giant);
 		break;
 	case SIOCGIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:14:07 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4246310656A5;
	Thu, 29 Oct 2009 23:14:07 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DD668FC2A;
	Thu, 29 Oct 2009 23:14:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNE7aQ014191;
	Thu, 29 Oct 2009 23:14:07 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNE7TL014189;
	Thu, 29 Oct 2009 23:14:07 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292314.n9TNE7TL014189@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:14:07 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198639 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/storage dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:14:07 -0000

Author: thompsa
Date: Thu Oct 29 23:14:06 2009
New Revision: 198639
URL: http://svn.freebsd.org/changeset/base/198639

Log:
  MFC r196826
  
   Make umass(4) pass device USB serial number to CAM, making it possible
   to e.g. retrieve it using camcontrol(8).

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/storage/umass.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/storage/umass.c
==============================================================================
--- stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:13:36 2009	(r198638)
+++ stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:14:06 2009	(r198639)
@@ -124,6 +124,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include "usbdevs.h"
 
 #include 
@@ -2979,6 +2980,28 @@ umass_cam_action(struct cam_sim *sim, un
 				if (sc->sc_transfer.cmd_data[0] == INQUIRY) {
 
 					/*
+					 * Umass devices don't generally report their serial numbers
+					 * in the usual SCSI way.  Emulate it here.
+					 */
+					if ((sc->sc_transfer.cmd_data[1] & SI_EVPD) &&
+					    sc->sc_transfer.cmd_data[2] == SVPD_UNIT_SERIAL_NUMBER &&
+					    sc->sc_udev != NULL &&
+					    sc->sc_udev->serial != NULL &&
+					    sc->sc_udev->serial[0] != '\0') {
+						struct scsi_vpd_unit_serial_number *vpd_serial;
+
+						vpd_serial = (struct scsi_vpd_unit_serial_number *)ccb->csio.data_ptr;
+						vpd_serial->length = strlen(sc->sc_udev->serial);
+						if (vpd_serial->length > sizeof(vpd_serial->serial_num))
+							vpd_serial->length = sizeof(vpd_serial->serial_num);
+						memcpy(vpd_serial->serial_num, sc->sc_udev->serial, vpd_serial->length);
+						ccb->csio.scsi_status = SCSI_STATUS_OK;
+						ccb->ccb_h.status = CAM_REQ_CMP;
+						xpt_done(ccb);
+						goto done;
+					}
+
+					/*
 					 * Handle EVPD inquiry for broken devices first
 					 * NO_INQUIRY also implies NO_INQUIRY_EVPD
 					 */
@@ -3194,6 +3217,29 @@ umass_cam_cb(struct umass_softc *sc, uni
 			maxsector = scsi_4btoul(rcap->addr) - 1;
 			scsi_ulto4b(maxsector, rcap->addr);
 		}
+		/*
+		 * We have to add SVPD_UNIT_SERIAL_NUMBER to the list
+		 * of pages supported by the device - otherwise, CAM
+		 * will never ask us for the serial number if the
+		 * device cannot handle that by itself.
+		 */
+		if (ccb->ccb_h.func_code == XPT_SCSI_IO &&
+		    sc->sc_transfer.cmd_data[0] == INQUIRY &&
+		    (sc->sc_transfer.cmd_data[1] & SI_EVPD) &&
+		    sc->sc_transfer.cmd_data[2] == SVPD_SUPPORTED_PAGE_LIST &&
+		    sc->sc_udev != NULL &&
+		    sc->sc_udev->serial != NULL &&
+		    sc->sc_udev->serial[0] != '\0') {
+			struct ccb_scsiio *csio;
+			struct scsi_vpd_supported_page_list *page_list;
+
+			csio = &ccb->csio;
+			page_list = (struct scsi_vpd_supported_page_list *)csio->data_ptr;
+			if (page_list->length + 1 < SVPD_SUPPORTED_PAGES_SIZE) {
+				page_list->list[page_list->length] = SVPD_UNIT_SERIAL_NUMBER;
+				page_list->length++;
+			}
+		}
 		xpt_done(ccb);
 		break;
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:14:40 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5B1D8106566B;
	Thu, 29 Oct 2009 23:14:40 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 45DE98FC0C;
	Thu, 29 Oct 2009 23:14:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNEeOH014255;
	Thu, 29 Oct 2009 23:14:40 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNEenR014249;
	Thu, 29 Oct 2009 23:14:40 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292314.n9TNEenR014249@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:14:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198640 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:14:40 -0000

Author: thompsa
Date: Thu Oct 29 23:14:39 2009
New Revision: 198640
URL: http://svn.freebsd.org/changeset/base/198640

Log:
  MFC r197553
  
   - clean up USB detach logic. There seems to be some problems detaching multiple
     USB HUBs connected in series from the root.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/controller/usb_controller.c
  stable/8/sys/dev/usb/usb_device.c
  stable/8/sys/dev/usb/usb_device.h
  stable/8/sys/dev/usb/usb_hub.c
  stable/8/sys/dev/usb/usb_transfer.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/controller/usb_controller.c
==============================================================================
--- stable/8/sys/dev/usb/controller/usb_controller.c	Thu Oct 29 23:14:06 2009	(r198639)
+++ stable/8/sys/dev/usb/controller/usb_controller.c	Thu Oct 29 23:14:39 2009	(r198640)
@@ -270,11 +270,9 @@ usb_bus_detach(struct usb_proc_msg *pm)
 	mtx_unlock(&Giant);
 
 	/*
-	 * Free USB Root device, but not any sub-devices, hence they
-	 * are freed by the caller of this function:
+	 * Free USB device and all subdevices, if any.
 	 */
-	usb_free_device(udev,
-	    USB_UNCFG_FLAG_FREE_EP0);
+	usb_free_device(udev, 0);
 
 	USB_BUS_LOCK(bus);
 	/* clear bdev variable last */

Modified: stable/8/sys/dev/usb/usb_device.c
==============================================================================
--- stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:14:06 2009	(r198639)
+++ stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:14:39 2009	(r198640)
@@ -478,7 +478,7 @@ usbd_set_config_index(struct usb_device 
 		usbd_enum_lock(udev);
 	}
 
-	usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV);
+	usb_unconfigure(udev, 0);
 
 	if (index == USB_UNCONFIG_INDEX) {
 		/*
@@ -582,7 +582,7 @@ usbd_set_config_index(struct usb_device 
 done:
 	DPRINTF("error=%s\n", usbd_errstr(err));
 	if (err) {
-		usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV);
+		usb_unconfigure(udev, 0);
 	}
 	if (do_unlock)
 		usbd_enum_unlock(udev);
@@ -989,18 +989,13 @@ usb_detach_device_sub(struct usb_device 
 	device_t dev;
 	int err;
 
-	if (!(flag & USB_UNCFG_FLAG_FREE_SUBDEV)) {
-
-		*ppdev = NULL;
-
-	} else if (*ppdev) {
-
+	dev = *ppdev;
+	if (dev) {
 		/*
 		 * NOTE: It is important to clear "*ppdev" before deleting
 		 * the child due to some device methods being called late
 		 * during the delete process !
 		 */
-		dev = *ppdev;
 		*ppdev = NULL;
 
 		device_printf(dev, "at %s, port %d, addr %d "
@@ -1778,7 +1773,7 @@ repeat_set_config:
 		} else if (usb_test_huawei_autoinst_p(udev, &uaa) == 0) {
 			DPRINTFN(0, "Found Huawei auto-install disk!\n");
 			/* leave device unconfigured */
-			usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV);
+			usb_unconfigure(udev, 0);
 		}
 	} else {
 		err = 0;		/* set success */
@@ -1803,10 +1798,10 @@ repeat_set_config:
 #endif
 done:
 	if (err) {
-		/* free device  */
-		usb_free_device(udev,
-		    USB_UNCFG_FLAG_FREE_SUBDEV |
-		    USB_UNCFG_FLAG_FREE_EP0);
+		/*
+		 * Free USB device and all subdevices, if any.
+		 */
+		usb_free_device(udev, 0);
 		udev = NULL;
 	}
 	return (udev);
@@ -1926,9 +1921,10 @@ usb_cdev_cleanup(void* arg)
 /*------------------------------------------------------------------------*
  *	usb_free_device
  *
- * This function is NULL safe and will free an USB device.
+ * This function is NULL safe and will free an USB device and its
+ * children devices, if any.
  *
- * Flag values, see "USB_UNCFG_FLAG_XXX".
+ * Flag values: Reserved, set to zero.
  *------------------------------------------------------------------------*/
 void
 usb_free_device(struct usb_device *udev, uint8_t flag)
@@ -1982,7 +1978,7 @@ usb_free_device(struct usb_device *udev,
 	}
 
 	/* the following will get the device unconfigured in software */
-	usb_unconfigure(udev, flag);
+	usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_EP0);
 
 	/* unsetup any leftover default USB transfers */
 	usbd_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);

Modified: stable/8/sys/dev/usb/usb_device.h
==============================================================================
--- stable/8/sys/dev/usb/usb_device.h	Thu Oct 29 23:14:06 2009	(r198639)
+++ stable/8/sys/dev/usb/usb_device.h	Thu Oct 29 23:14:39 2009	(r198640)
@@ -41,7 +41,6 @@ struct usb_device;		/* linux compat */
 /* "usb_unconfigure()" flags */
 
 #define	USB_UNCFG_FLAG_NONE 0x00
-#define	USB_UNCFG_FLAG_FREE_SUBDEV 0x01		/* subdevices are freed */
 #define	USB_UNCFG_FLAG_FREE_EP0	0x02		/* endpoint zero is freed */
 
 struct usb_clear_stall_msg {

Modified: stable/8/sys/dev/usb/usb_hub.c
==============================================================================
--- stable/8/sys/dev/usb/usb_hub.c	Thu Oct 29 23:14:06 2009	(r198639)
+++ stable/8/sys/dev/usb/usb_hub.c	Thu Oct 29 23:14:39 2009	(r198640)
@@ -316,12 +316,13 @@ repeat:
 	if (err) {
 		goto error;
 	}
-	/* detach any existing devices */
+	/* check if there is a child */
 
-	if (child) {
-		usb_free_device(child,
-		    USB_UNCFG_FLAG_FREE_SUBDEV |
-		    USB_UNCFG_FLAG_FREE_EP0);
+	if (child != NULL) {
+		/*
+		 * Free USB device and all subdevices, if any.
+		 */
+		usb_free_device(child, 0);
 		child = NULL;
 	}
 	/* get fresh status */
@@ -438,10 +439,11 @@ repeat:
 	return (0);			/* success */
 
 error:
-	if (child) {
-		usb_free_device(child,
-		    USB_UNCFG_FLAG_FREE_SUBDEV |
-		    USB_UNCFG_FLAG_FREE_EP0);
+	if (child != NULL) {
+		/*
+		 * Free USB device and all subdevices, if any.
+		 */
+		usb_free_device(child, 0);
 		child = NULL;
 	}
 	if (err == 0) {
@@ -888,12 +890,14 @@ uhub_detach(device_t dev)
 	struct usb_device *child;
 	uint8_t x;
 
-	/* detach all children first */
-	bus_generic_detach(dev);
-
 	if (hub == NULL) {		/* must be partially working */
 		return (0);
 	}
+
+	/* Make sure interrupt transfer is gone. */
+	usbd_transfer_unsetup(sc->sc_xfer, UHUB_N_TRANSFER);
+
+	/* Detach all ports */
 	for (x = 0; x != hub->nports; x++) {
 
 		child = usb_bus_port_get_device(sc->sc_udev->bus, hub->ports + x);
@@ -901,16 +905,13 @@ uhub_detach(device_t dev)
 		if (child == NULL) {
 			continue;
 		}
+
 		/*
-		 * Subdevices are not freed, because the caller of
-		 * uhub_detach() will do that.
+		 * Free USB device and all subdevices, if any.
 		 */
-		usb_free_device(child,
-		    USB_UNCFG_FLAG_FREE_EP0);
+		usb_free_device(child, 0);
 	}
 
-	usbd_transfer_unsetup(sc->sc_xfer, UHUB_N_TRANSFER);
-
 	free(hub, M_USBDEV);
 	sc->sc_udev->hub = NULL;
 
@@ -984,10 +985,19 @@ static int
 uhub_child_location_string(device_t parent, device_t child,
     char *buf, size_t buflen)
 {
-	struct uhub_softc *sc = device_get_softc(parent);
-	struct usb_hub *hub = sc->sc_udev->hub;
+	struct uhub_softc *sc;
+	struct usb_hub *hub;
 	struct hub_result res;
 
+	if (!device_is_attached(parent)) {
+		if (buflen)
+			buf[0] = 0;
+		return (0);
+	}
+
+	sc = device_get_softc(parent);
+	hub = sc->sc_udev->hub;
+
 	mtx_lock(&Giant);
 	uhub_find_iface_index(hub, child, &res);
 	if (!res.udev) {
@@ -1009,11 +1019,20 @@ static int
 uhub_child_pnpinfo_string(device_t parent, device_t child,
     char *buf, size_t buflen)
 {
-	struct uhub_softc *sc = device_get_softc(parent);
-	struct usb_hub *hub = sc->sc_udev->hub;
+	struct uhub_softc *sc;
+	struct usb_hub *hub;
 	struct usb_interface *iface;
 	struct hub_result res;
 
+	if (!device_is_attached(parent)) {
+		if (buflen)
+			buf[0] = 0;
+		return (0);
+	}
+
+	sc = device_get_softc(parent);
+	hub = sc->sc_udev->hub;
+
 	mtx_lock(&Giant);
 	uhub_find_iface_index(hub, child, &res);
 	if (!res.udev) {

Modified: stable/8/sys/dev/usb/usb_transfer.c
==============================================================================
--- stable/8/sys/dev/usb/usb_transfer.c	Thu Oct 29 23:14:06 2009	(r198639)
+++ stable/8/sys/dev/usb/usb_transfer.c	Thu Oct 29 23:14:39 2009	(r198640)
@@ -2121,6 +2121,9 @@ usb_dma_delay_done_cb(void *arg)
 
 	DPRINTFN(3, "Completed %p\n", xfer);
 
+	/* only delay once */
+	xfer->flags_int.did_dma_delay = 1;
+
 	/* queue callback for execution, again */
 	usbd_transfer_done(xfer, 0);
 }
@@ -2488,9 +2491,6 @@ usbd_callback_wrapper_sub(struct usb_xfe
 
 		usb_timeout_t temp;
 
-		/* only delay once */
-		xfer->flags_int.did_dma_delay = 1;
-
 		/* we can not cancel this delay */
 		xfer->flags_int.can_cancel_immed = 0;
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:15:27 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 817B010656BC;
	Thu, 29 Oct 2009 23:15:27 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 535508FC14;
	Thu, 29 Oct 2009 23:15:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNFR4H014330;
	Thu, 29 Oct 2009 23:15:27 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNFR0X014328;
	Thu, 29 Oct 2009 23:15:27 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292315.n9TNFR0X014328@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:15:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198641 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:15:27 -0000

Author: thompsa
Date: Thu Oct 29 23:15:26 2009
New Revision: 198641
URL: http://svn.freebsd.org/changeset/base/198641

Log:
  MFC r197554
  
   Import two PCI quirks from Linux
  
    - Add quirk for ATI SB600 and SB700 to free SMB controller
    - Correct schedule sleep time to 10us on the VIA ehci controller

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/controller/ehci_pci.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/controller/ehci_pci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci_pci.c	Thu Oct 29 23:14:39 2009	(r198640)
+++ stable/8/sys/dev/usb/controller/ehci_pci.c	Thu Oct 29 23:15:26 2009	(r198641)
@@ -240,6 +240,50 @@ ehci_pci_probe(device_t self)
 	}
 }
 
+static void
+ehci_pci_ati_quirk(device_t self, uint8_t is_sb700)
+{
+	device_t smbdev;
+	uint32_t val;
+
+	if (is_sb700) {
+		/* Lookup SMBUS PCI device */
+		smbdev = pci_find_device(PCI_EHCI_VENDORID_ATI, 0x4385);
+		if (smbdev == NULL)
+			return;
+		val = pci_get_revid(smbdev);
+		if (val != 0x3a && val != 0x3b)
+			return;
+	}
+
+	/*
+	 * Note: this bit is described as reserved in SB700
+	 * Register Reference Guide.
+	 */
+	val = pci_read_config(self, 0x53, 1);
+	if (!(val & 0x8)) {
+		val |= 0x8;
+		pci_write_config(self, 0x53, val, 1);
+		device_printf(self, "AMD SB600/700 quirk applied\n");
+	}
+}
+
+static void
+ehci_pci_via_quirk(device_t self)
+{
+	uint32_t val;
+
+	if ((pci_get_device(self) == 0x3104) && 
+	    ((pci_get_revid(self) & 0xf0) == 0x60)) {
+		/* Correct schedule sleep time to 10us */
+		val = pci_read_config(self, 0x4b, 1);
+		if (val & 0x20)
+			return;
+		pci_write_config(self, 0x4b, val, 1);
+		device_printf(self, "VIA-quirk applied\n");
+	}
+}
+
 static int
 ehci_pci_attach(device_t self)
 {
@@ -370,6 +414,32 @@ ehci_pci_attach(device_t self)
 		goto error;
 	}
 	ehci_pci_takecontroller(self);
+
+	/* Undocumented quirks taken from Linux */
+
+	switch (pci_get_vendor(self)) {
+	case PCI_EHCI_VENDORID_ATI:
+		/* SB600 and SB700 EHCI quirk */
+		switch (pci_get_device(self)) {
+		case 0x4386:
+			ehci_pci_ati_quirk(self, 0);
+			break;
+		case 0x4396:
+			ehci_pci_ati_quirk(self, 1);
+			break;
+		default:
+			break;
+		}
+		break;
+
+	case PCI_EHCI_VENDORID_VIA:
+		ehci_pci_via_quirk(self);
+		break;
+
+	default:
+		break;
+	}
+
 	err = ehci_init(sc);
 	if (!err) {
 		err = device_probe_and_attach(sc->sc_bus.bdev);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:16:01 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 16AE3106568B;
	Thu, 29 Oct 2009 23:16:01 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 023738FC14;
	Thu, 29 Oct 2009 23:16:01 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNG0Zg014386;
	Thu, 29 Oct 2009 23:16:00 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNG06w014384;
	Thu, 29 Oct 2009 23:16:00 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292316.n9TNG06w014384@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:16:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198642 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:16:01 -0000

Author: thompsa
Date: Thu Oct 29 23:16:00 2009
New Revision: 198642
URL: http://svn.freebsd.org/changeset/base/198642

Log:
  MFC r197555
  
   Simplify logic around setting EHCI_QH_DTC and expand some htohc32(temp.sc, 0)
   statements to zero.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/controller/ehci.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/controller/ehci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci.c	Thu Oct 29 23:15:26 2009	(r198641)
+++ stable/8/sys/dev/usb/controller/ehci.c	Thu Oct 29 23:16:00 2009	(r198642)
@@ -1954,18 +1954,15 @@ ehci_setup_standard_chain(struct usb_xfe
 	    EHCI_QH_SET_MPL(xfer->max_packet_size));
 
 	if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_HIGH) {
-		qh_endp |= (EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH) |
-		    EHCI_QH_DTC);
+		qh_endp |= EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH);
 		if (methods != &ehci_device_intr_methods)
 			qh_endp |= EHCI_QH_SET_NRL(8);
 	} else {
 
 		if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_FULL) {
-			qh_endp |= (EHCI_QH_SET_EPS(EHCI_QH_SPEED_FULL) |
-			    EHCI_QH_DTC);
+			qh_endp |= EHCI_QH_SET_EPS(EHCI_QH_SPEED_FULL);
 		} else {
-			qh_endp |= (EHCI_QH_SET_EPS(EHCI_QH_SPEED_LOW) |
-			    EHCI_QH_DTC);
+			qh_endp |= EHCI_QH_SET_EPS(EHCI_QH_SPEED_LOW);
 		}
 
 		if (methods == &ehci_device_ctrl_methods) {
@@ -1977,6 +1974,11 @@ ehci_setup_standard_chain(struct usb_xfe
 		}
 	}
 
+	if (temp.auto_data_toggle == 0) {
+		/* software computes the data toggle */
+		qh_endp |= EHCI_QH_DTC;
+	}
+
 	qh->qh_endp = htohc32(temp.sc, qh_endp);
 
 	qh_endphub =
@@ -1987,23 +1989,17 @@ ehci_setup_standard_chain(struct usb_xfe
 	    EHCI_QH_SET_PORT(xfer->xroot->udev->hs_port_no));
 
 	qh->qh_endphub = htohc32(temp.sc, qh_endphub);
-	qh->qh_curqtd = htohc32(temp.sc, 0);
+	qh->qh_curqtd = 0;
 
 	/* fill the overlay qTD */
-	qh->qh_qtd.qtd_status = htohc32(temp.sc, 0);
-
-	if (temp.auto_data_toggle) {
-
-		/* let the hardware compute the data toggle */
 
-		qh->qh_endp &= htohc32(temp.sc, ~EHCI_QH_DTC);
-
-		if (xfer->endpoint->toggle_next) {
-			/* DATA1 is next */
-			qh->qh_qtd.qtd_status |=
-			    htohc32(temp.sc, EHCI_QTD_SET_TOGGLE(1));
-		}
+	if (temp.auto_data_toggle && xfer->endpoint->toggle_next) {
+		/* DATA1 is next */
+		qh->qh_qtd.qtd_status = htohc32(temp.sc, EHCI_QTD_SET_TOGGLE(1));
+	} else {
+		qh->qh_qtd.qtd_status = 0;
 	}
+
 	td = xfer->td_transfer_first;
 
 	qh->qh_qtd.qtd_next = td->qtd_self;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:16:39 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E5C7610656CF;
	Thu, 29 Oct 2009 23:16:39 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D16F38FC22;
	Thu, 29 Oct 2009 23:16:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNGd4C014449;
	Thu, 29 Oct 2009 23:16:39 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNGd3X014447;
	Thu, 29 Oct 2009 23:16:39 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292316.n9TNGd3X014447@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:16:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198643 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:16:40 -0000

Author: thompsa
Date: Thu Oct 29 23:16:39 2009
New Revision: 198643
URL: http://svn.freebsd.org/changeset/base/198643

Log:
  MFC r197556
  
   Clear all interrupts rather than just SETUP packet.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/controller/atmegadci.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/controller/atmegadci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/atmegadci.c	Thu Oct 29 23:16:00 2009	(r198642)
+++ stable/8/sys/dev/usb/controller/atmegadci.c	Thu Oct 29 23:16:39 2009	(r198643)
@@ -301,8 +301,8 @@ atmegadci_setup_rx(struct atmegadci_td *
 		sc->sc_dv_addr = 0xFF;
 	}
 
-	/* clear SETUP packet interrupt */
-	ATMEGA_WRITE_1(sc, ATMEGA_UEINTX, ~ATMEGA_UEINTX_RXSTPI);
+	/* Clear SETUP packet interrupt and all other previous interrupts */
+	ATMEGA_WRITE_1(sc, ATMEGA_UEINTX, 0);
 	return (0);			/* complete */
 
 not_complete:

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:17:24 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 042D6106568D;
	Thu, 29 Oct 2009 23:17:24 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E41418FC0A;
	Thu, 29 Oct 2009 23:17:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNHNel014517;
	Thu, 29 Oct 2009 23:17:23 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNHN76014515;
	Thu, 29 Oct 2009 23:17:23 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292317.n9TNHN76014515@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:17:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198644 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:17:24 -0000

Author: thompsa
Date: Thu Oct 29 23:17:23 2009
New Revision: 198644
URL: http://svn.freebsd.org/changeset/base/198644

Log:
  MFC r197558
  
   Fix NULL-pointer dereference in usb_endpoint_foreach().
  
  PR:		usb/138389

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usb_device.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usb_device.c
==============================================================================
--- stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:16:39 2009	(r198643)
+++ stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:17:23 2009	(r198644)
@@ -367,12 +367,14 @@ usb_init_endpoint(struct usb_device *ude
 struct usb_endpoint *
 usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep)
 {
-	struct usb_endpoint *ep_end = udev->endpoints + udev->endpoints_max;
+	struct usb_endpoint *ep_end;
 
 	/* be NULL safe */
 	if (udev == NULL)
 		return (NULL);
 
+	ep_end = udev->endpoints + udev->endpoints_max;
+
 	/* get next endpoint */
 	if (ep == NULL)
 		ep = udev->endpoints;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:17:54 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B915E1065692;
	Thu, 29 Oct 2009 23:17:54 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A43C58FC0A;
	Thu, 29 Oct 2009 23:17:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNHsc5014575;
	Thu, 29 Oct 2009 23:17:54 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNHsNv014572;
	Thu, 29 Oct 2009 23:17:54 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292317.n9TNHsNv014572@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:17:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198645 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:17:54 -0000

Author: thompsa
Date: Thu Oct 29 23:17:54 2009
New Revision: 198645
URL: http://svn.freebsd.org/changeset/base/198645

Log:
  MFC r197559
  
   Add support for USB language selection.
  
  PR:		usb/138563

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usb_bus.h
  stable/8/sys/dev/usb/usb_device.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usb_bus.h
==============================================================================
--- stable/8/sys/dev/usb/usb_bus.h	Thu Oct 29 23:17:23 2009	(r198644)
+++ stable/8/sys/dev/usb/usb_bus.h	Thu Oct 29 23:17:54 2009	(r198645)
@@ -98,10 +98,14 @@ struct usb_bus {
 	uint8_t	devices_max;		/* maximum number of USB devices */
 	uint8_t	do_probe;		/* set if USB BUS should be re-probed */
 
+	/* 
+	 * The scratch area can only be used inside the explore thread
+	 * belonging to the give serial bus.
+	 */
 	union {
 		struct usb_hw_ep_scratch hw_ep_scratch[1];
 		struct usb_temp_setup temp_setup[1];
-		uint8_t	data[128];
+		uint8_t	data[255];
 	}	scratch[1];
 };
 

Modified: stable/8/sys/dev/usb/usb_device.c
==============================================================================
--- stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:17:23 2009	(r198644)
+++ stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:17:54 2009	(r198645)
@@ -105,9 +105,23 @@ static void	usb_cdev_cleanup(void *);
 
 int	usb_template = 0;
 
+TUNABLE_INT("hw.usb.usb_template", &usb_template);
 SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW,
     &usb_template, 0, "Selected USB device side template");
 
+/* English is default language */
+
+static int usb_lang_id = 0x0009;
+static int usb_lang_mask = 0x00FF;
+
+TUNABLE_INT("hw.usb.usb_lang_id", &usb_lang_id);
+SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RW,
+    &usb_lang_id, 0, "Preferred USB language ID");
+
+TUNABLE_INT("hw.usb.usb_lang_mask", &usb_lang_mask);
+SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RW,
+    &usb_lang_mask, 0, "Preferred USB language mask");
+
 static const char* statestr[USB_STATE_MAX] = {
 	[USB_STATE_DETACHED]	= "DETACHED",
 	[USB_STATE_ATTACHED]	= "ATTACHED",
@@ -1436,7 +1450,7 @@ usb_alloc_device(device_t parent_dev, st
 	struct usb_device *adev;
 	struct usb_device *hub;
 	uint8_t *scratch_ptr;
-	uint32_t scratch_size;
+	size_t scratch_size;
 	usb_error_t err;
 	uint8_t device_index;
 
@@ -1682,8 +1696,35 @@ usb_alloc_device(device_t parent_dev, st
 	if (err || (scratch_ptr[0] < 4)) {
 		udev->flags.no_strings = 1;
 	} else {
-		/* pick the first language as the default */
-		udev->langid = UGETW(scratch_ptr + 2);
+		uint16_t langid;
+		uint16_t pref;
+		uint16_t mask;
+		uint8_t x;
+
+		/* load preferred value and mask */
+		pref = usb_lang_id;
+		mask = usb_lang_mask;
+
+		/* align length correctly */
+		scratch_ptr[0] &= ~1;
+
+		/* fix compiler warning */
+		langid = 0;
+
+		/* search for preferred language */
+		for (x = 2; (x < scratch_ptr[0]); x += 2) {
+			langid = UGETW(scratch_ptr + x);
+			if ((langid & mask) == pref)
+				break;
+		}
+		if (x >= scratch_ptr[0]) {
+			/* pick the first language as the default */
+			DPRINTFN(1, "Using first language\n");
+			langid = UGETW(scratch_ptr + 2);
+		}
+
+		DPRINTFN(1, "Language selected: 0x%04x\n", langid);
+		udev->langid = langid;
 	}
 
 	/* assume 100mA bus powered for now. Changed when configured. */
@@ -2149,34 +2190,35 @@ usbd_set_device_strings(struct usb_devic
 #ifdef USB_VERBOSE
 	const struct usb_knowndev *kdp;
 #endif
-	char temp[64];
+	uint8_t *temp_ptr;
+	size_t temp_size;
 	uint16_t vendor_id;
 	uint16_t product_id;
 
+	temp_ptr = udev->bus->scratch[0].data;
+	temp_size = sizeof(udev->bus->scratch[0].data);
+
 	vendor_id = UGETW(udd->idVendor);
 	product_id = UGETW(udd->idProduct);
 
 	/* get serial number string */
-	bzero(temp, sizeof(temp));
-	usbd_req_get_string_any(udev, NULL, temp, sizeof(temp),
+	usbd_req_get_string_any(udev, NULL, temp_ptr, temp_size,
 	    udev->ddesc.iSerialNumber);
-	udev->serial = strdup(temp, M_USB);
+	udev->serial = strdup(temp_ptr, M_USB);
 
 	/* get manufacturer string */
-	bzero(temp, sizeof(temp));
-	usbd_req_get_string_any(udev, NULL, temp, sizeof(temp),
+	usbd_req_get_string_any(udev, NULL, temp_ptr, temp_size,
 	    udev->ddesc.iManufacturer);
-	usb_trim_spaces(temp);
-	if (temp[0] != '\0')
-		udev->manufacturer = strdup(temp, M_USB);
+	usb_trim_spaces(temp_ptr);
+	if (temp_ptr[0] != '\0')
+		udev->manufacturer = strdup(temp_ptr, M_USB);
 
 	/* get product string */
-	bzero(temp, sizeof(temp));
-	usbd_req_get_string_any(udev, NULL, temp, sizeof(temp),
+	usbd_req_get_string_any(udev, NULL, temp_ptr, temp_size,
 	    udev->ddesc.iProduct);
-	usb_trim_spaces(temp);
-	if (temp[0] != '\0')
-		udev->product = strdup(temp, M_USB);
+	usb_trim_spaces(temp_ptr);
+	if (temp_ptr[0] != '\0')
+		udev->product = strdup(temp_ptr, M_USB);
 
 #ifdef USB_VERBOSE
 	if (udev->manufacturer == NULL || udev->product == NULL) {
@@ -2202,12 +2244,12 @@ usbd_set_device_strings(struct usb_devic
 #endif
 	/* Provide default strings if none were found */
 	if (udev->manufacturer == NULL) {
-		snprintf(temp, sizeof(temp), "vendor 0x%04x", vendor_id);
-		udev->manufacturer = strdup(temp, M_USB);
+		snprintf(temp_ptr, temp_size, "vendor 0x%04x", vendor_id);
+		udev->manufacturer = strdup(temp_ptr, M_USB);
 	}
 	if (udev->product == NULL) {
-		snprintf(temp, sizeof(temp), "product 0x%04x", product_id);
-		udev->product = strdup(temp, M_USB);
+		snprintf(temp_ptr, temp_size, "product 0x%04x", product_id);
+		udev->product = strdup(temp_ptr, M_USB);
 	}
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:18:27 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 71D9D106568F;
	Thu, 29 Oct 2009 23:18:27 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DB188FC08;
	Thu, 29 Oct 2009 23:18:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNIRqN014636;
	Thu, 29 Oct 2009 23:18:27 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNIRrX014634;
	Thu, 29 Oct 2009 23:18:27 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292318.n9TNIRrX014634@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:18:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198646 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:18:27 -0000

Author: thompsa
Date: Thu Oct 29 23:18:27 2009
New Revision: 198646
URL: http://svn.freebsd.org/changeset/base/198646

Log:
  MFC r197561
  
   Correct buffer sizes used so that they match. The old code could give the
   impression that a overflow situation existed but was not possible.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usb_device.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usb_device.c
==============================================================================
--- stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:17:54 2009	(r198645)
+++ stable/8/sys/dev/usb/usb_device.c	Thu Oct 29 23:18:27 2009	(r198646)
@@ -2355,6 +2355,7 @@ usb_notify_addq(const char *type, struct
 {
 	char *data = NULL;
 	struct malloc_type *mt;
+	const size_t buf_size = 512;
 
 	mtx_lock(&malloc_mtx);
 	mt = malloc_desc2type("bus");	/* XXX M_BUS */
@@ -2362,12 +2363,12 @@ usb_notify_addq(const char *type, struct
 	if (mt == NULL)
 		return;
 
-	data = malloc(512, mt, M_NOWAIT);
+	data = malloc(buf_size, mt, M_NOWAIT);
 	if (data == NULL)
 		return;
 
 	/* String it all together. */
-	snprintf(data, 1024,
+	snprintf(data, buf_size,
 	    "%s"
 	    "%s "
 	    "vendor=0x%04x "

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:18:59 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B02CF1065692;
	Thu, 29 Oct 2009 23:18:59 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9B6E98FC08;
	Thu, 29 Oct 2009 23:18:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNIxOk014694;
	Thu, 29 Oct 2009 23:18:59 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNIxVD014692;
	Thu, 29 Oct 2009 23:18:59 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292318.n9TNIxVD014692@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:18:59 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198647 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:18:59 -0000

Author: thompsa
Date: Thu Oct 29 23:18:59 2009
New Revision: 198647
URL: http://svn.freebsd.org/changeset/base/198647

Log:
  MFC r197562
  
   Add extra safety locking when clobbering xfer->flags_int.started in start and
   stop functions, because xfer->flags_int is also updated by the USB controller,
   under the controller lock.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usb_transfer.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usb_transfer.c
==============================================================================
--- stable/8/sys/dev/usb/usb_transfer.c	Thu Oct 29 23:18:27 2009	(r198646)
+++ stable/8/sys/dev/usb/usb_transfer.c	Thu Oct 29 23:18:59 2009	(r198647)
@@ -1332,7 +1332,9 @@ usbd_setup_ctrl_transfer(struct usb_xfer
 	/* check if there is a length mismatch */
 
 	if (len > xfer->flags_int.control_rem) {
-		DPRINTFN(0, "Length greater than remaining length!\n");
+		DPRINTFN(0, "Length (%d) greater than "
+		    "remaining length (%d)!\n", len,
+		    xfer->flags_int.control_rem);
 		goto error;
 	}
 	/* check if we are doing a short transfer */
@@ -1620,7 +1622,10 @@ usbd_transfer_start(struct usb_xfer *xfe
 	/* mark the USB transfer started */
 
 	if (!xfer->flags_int.started) {
+		/* lock the BUS lock to avoid races updating flags_int */
+		USB_BUS_LOCK(xfer->xroot->bus);
 		xfer->flags_int.started = 1;
+		USB_BUS_UNLOCK(xfer->xroot->bus);
 	}
 	/* check if the USB transfer callback is already transferring */
 
@@ -1655,14 +1660,21 @@ usbd_transfer_stop(struct usb_xfer *xfer
 	/* check if the USB transfer was ever opened */
 
 	if (!xfer->flags_int.open) {
-		/* nothing to do except clearing the "started" flag */
-		xfer->flags_int.started = 0;
+		if (xfer->flags_int.started) {
+			/* nothing to do except clearing the "started" flag */
+			/* lock the BUS lock to avoid races updating flags_int */
+			USB_BUS_LOCK(xfer->xroot->bus);
+			xfer->flags_int.started = 0;
+			USB_BUS_UNLOCK(xfer->xroot->bus);
+		}
 		return;
 	}
 	/* try to stop the current USB transfer */
 
 	USB_BUS_LOCK(xfer->xroot->bus);
-	xfer->error = USB_ERR_CANCELLED;/* override any previous error */
+	/* override any previous error */
+	xfer->error = USB_ERR_CANCELLED;
+
 	/*
 	 * Clear "open" and "started" when both private and USB lock
 	 * is locked so that we don't get a race updating "flags_int"
@@ -2121,9 +2133,6 @@ usb_dma_delay_done_cb(void *arg)
 
 	DPRINTFN(3, "Completed %p\n", xfer);
 
-	/* only delay once */
-	xfer->flags_int.did_dma_delay = 1;
-
 	/* queue callback for execution, again */
 	usbd_transfer_done(xfer, 0);
 }
@@ -2193,6 +2202,8 @@ usbd_transfer_done(struct usb_xfer *xfer
 	 */
 	if (!xfer->flags_int.transferring) {
 		DPRINTF("not transferring\n");
+		/* end of control transfer, if any */
+		xfer->flags_int.control_act = 0;
 		return;
 	}
 	/* only set transfer error if not already set */
@@ -2491,6 +2502,9 @@ usbd_callback_wrapper_sub(struct usb_xfe
 
 		usb_timeout_t temp;
 
+		/* only delay once */
+		xfer->flags_int.did_dma_delay = 1;
+
 		/* we can not cancel this delay */
 		xfer->flags_int.can_cancel_immed = 0;
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:19:41 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CFDC210656BF;
	Thu, 29 Oct 2009 23:19:41 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B9CB78FC12;
	Thu, 29 Oct 2009 23:19:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNJfem014760;
	Thu, 29 Oct 2009 23:19:41 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNJftq014755;
	Thu, 29 Oct 2009 23:19:41 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292319.n9TNJftq014755@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:19:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198648 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:19:42 -0000

Author: thompsa
Date: Thu Oct 29 23:19:41 2009
New Revision: 198648
URL: http://svn.freebsd.org/changeset/base/198648

Log:
  MFC r197563
  
   Add basic support for USB Network Control Model (NCM) v1.0 to if_cdce.c.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_cdce.c
  stable/8/sys/dev/usb/net/if_cdcereg.h
  stable/8/sys/dev/usb/usb.h
  stable/8/sys/dev/usb/usb_cdc.h
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_cdce.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:18:59 2009	(r198647)
+++ stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:19:41 2009	(r198648)
@@ -40,6 +40,11 @@
  * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
  */
 
+/*
+ * USB Network Control Model (NCM)
+ * http://www.usb.org/developers/devclass_docs/NCM10.zip
+ */
+
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -89,6 +94,11 @@ static usb_callback_t cdce_bulk_read_cal
 static usb_callback_t cdce_intr_read_callback;
 static usb_callback_t cdce_intr_write_callback;
 
+#if CDCE_HAVE_NCM
+static usb_callback_t cdce_ncm_bulk_write_callback;
+static usb_callback_t cdce_ncm_bulk_read_callback;
+#endif
+
 static uether_fn_t cdce_attach_post;
 static uether_fn_t cdce_init;
 static uether_fn_t cdce_stop;
@@ -159,6 +169,61 @@ static const struct usb_config cdce_conf
 	},
 };
 
+#if CDCE_HAVE_NCM
+static const struct usb_config cdce_ncm_config[CDCE_N_TRANSFER] = {
+
+	[CDCE_BULK_RX] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_RX,
+		.if_index = 0,
+		.frames = CDCE_NCM_RX_FRAMES_MAX,
+		.bufsize = (CDCE_NCM_RX_FRAMES_MAX * CDCE_NCM_RX_MAXLEN),
+		.flags = {.pipe_bof = 1,.short_frames_ok = 1,.short_xfer_ok = 1,},
+		.callback = cdce_ncm_bulk_read_callback,
+		.timeout = 0,	/* no timeout */
+		.usb_mode = USB_MODE_DUAL,	/* both modes */
+	},
+
+	[CDCE_BULK_TX] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_TX,
+		.if_index = 0,
+		.frames = CDCE_NCM_TX_FRAMES_MAX,
+		.bufsize = (CDCE_NCM_TX_FRAMES_MAX * CDCE_NCM_TX_MAXLEN),
+		.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
+		.callback = cdce_ncm_bulk_write_callback,
+		.timeout = 10000,	/* 10 seconds */
+		.usb_mode = USB_MODE_DUAL,	/* both modes */
+	},
+
+	[CDCE_INTR_RX] = {
+		.type = UE_INTERRUPT,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_RX,
+		.if_index = 1,
+		.bufsize = CDCE_IND_SIZE_MAX,
+		.flags = {.pipe_bof = 1,.short_xfer_ok = 1,.no_pipe_ok = 1,},
+		.callback = cdce_intr_read_callback,
+		.timeout = 0,
+		.usb_mode = USB_MODE_HOST,
+	},
+
+	[CDCE_INTR_TX] = {
+		.type = UE_INTERRUPT,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_TX,
+		.if_index = 1,
+		.bufsize = CDCE_IND_SIZE_MAX,
+		.flags = {.pipe_bof = 1,.force_short_xfer = 1,.no_pipe_ok = 1,},
+		.callback = cdce_intr_write_callback,
+		.timeout = 10000,	/* 10 seconds */
+		.usb_mode = USB_MODE_DEVICE,
+	},
+};
+#endif
+
 static device_method_t cdce_methods[] = {
 	/* USB interface */
 	DEVMETHOD(usb_handle_request, cdce_handle_request),
@@ -213,8 +278,151 @@ static const struct usb_device_id cdce_d
 
 	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)},
 	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
+	{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_NETWORK_CONTROL_MODEL, 0)},
 };
 
+#if CDCE_HAVE_NCM
+/*------------------------------------------------------------------------*
+ *	cdce_ncm_init
+ *
+ * Return values:
+ * 0: Success
+ * Else: Failure
+ *------------------------------------------------------------------------*/
+static uint8_t
+cdce_ncm_init(struct cdce_softc *sc)
+{
+	struct usb_ncm_parameters temp;
+	struct usb_device_request req;
+	uDWord value;
+	int err;
+
+	req.bmRequestType = UT_READ_CLASS_INTERFACE;
+	req.bRequest = UCDC_NCM_GET_NTB_PARAMETERS;
+	USETW(req.wValue, 0);
+	req.wIndex[0] = sc->sc_ifaces_index[1];
+	req.wIndex[1] = 0;
+	USETW(req.wLength, sizeof(temp));
+
+	err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req,
+	    &temp, 0, NULL, 1000 /* ms */);
+	if (err)
+		return (1);
+
+	/* Read correct set of parameters according to device mode */
+
+	if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) {
+		sc->sc_ncm.rx_max = UGETW(temp.dwNtbInMaxSize);
+		sc->sc_ncm.tx_max = UGETW(temp.dwNtbOutMaxSize);
+		sc->sc_ncm.tx_remainder = UGETW(temp.wNdpOutPayloadRemainder);
+		sc->sc_ncm.tx_modulus = UGETW(temp.wNdpOutDivisor);
+		sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpOutAlignment);
+	} else {
+		sc->sc_ncm.rx_max = UGETW(temp.dwNtbOutMaxSize);
+		sc->sc_ncm.tx_max = UGETW(temp.dwNtbInMaxSize);
+		sc->sc_ncm.tx_remainder = UGETW(temp.wNdpInPayloadRemainder);
+		sc->sc_ncm.tx_modulus = UGETW(temp.wNdpInDivisor);
+		sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpInAlignment);
+	}
+
+	/* Verify maximum receive length */
+
+	if (err || (sc->sc_ncm.rx_max < 32) || 
+	    (sc->sc_ncm.rx_max > CDCE_NCM_RX_MAXLEN)) {
+		DPRINTFN(1, "Using default maximum receive length\n");
+		sc->sc_ncm.rx_max = CDCE_NCM_RX_MAXLEN;
+	}
+
+	/* Verify maximum transmit length */
+
+	if (err || (sc->sc_ncm.tx_max < 32) ||
+	    (sc->sc_ncm.tx_max > CDCE_NCM_TX_MAXLEN)) {
+		DPRINTFN(1, "Using default maximum transmit length\n");
+		sc->sc_ncm.tx_max = CDCE_NCM_TX_MAXLEN;
+	}
+
+	/* 
+	 * Verify that the structure alignment is:
+	 * - power of two
+	 * - not greater than the maximum transmit length
+	 * - not less than four bytes
+	 */
+	if (err || (sc->sc_ncm.tx_struct_align < 4) ||
+	    (sc->sc_ncm.tx_struct_align != 
+	     ((-sc->sc_ncm.tx_struct_align) & sc->sc_ncm.tx_struct_align)) ||
+	    (sc->sc_ncm.tx_struct_align >= sc->sc_ncm.tx_max)) {
+		DPRINTFN(1, "Using default other alignment: 4 bytes\n");
+		sc->sc_ncm.tx_struct_align = 4;
+	}
+
+	/* 
+	 * Verify that the payload alignment is:
+	 * - power of two
+	 * - not greater than the maximum transmit length
+	 * - not less than four bytes
+	 */
+	if (err || (sc->sc_ncm.tx_modulus < 4) ||
+	    (sc->sc_ncm.tx_modulus !=
+	     ((-sc->sc_ncm.tx_modulus) & sc->sc_ncm.tx_modulus)) ||
+	    (sc->sc_ncm.tx_modulus >= sc->sc_ncm.tx_max)) {
+		DPRINTFN(1, "Using default transmit modulus: 4 bytes\n");
+		sc->sc_ncm.tx_modulus = 4;
+	}
+
+	/* Verify that the payload remainder */
+
+	if (err || (sc->sc_ncm.tx_remainder >= sc->sc_ncm.tx_modulus)) {
+		DPRINTFN(1, "Using default transmit remainder: 0 bytes\n");
+		sc->sc_ncm.tx_remainder = 0;
+	}
+
+	/* Additional configuration, will fail in device side mode, which is OK. */
+
+	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+	req.bRequest = UCDC_NCM_SET_NTB_INPUT_SIZE;
+	USETW(req.wValue, 0);
+	req.wIndex[0] = sc->sc_ifaces_index[1];
+	req.wIndex[1] = 0;
+	USETW(req.wLength, 4);
+	USETDW(value, sc->sc_ncm.rx_max);
+
+	err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req,
+	    &value, 0, NULL, 1000 /* ms */);
+	if (err) {
+		DPRINTFN(1, "Setting input size "
+		    "to %u failed.\n", sc->sc_ncm.rx_max);
+	}
+
+	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+	req.bRequest = UCDC_NCM_SET_CRC_MODE;
+	USETW(req.wValue, 0);	/* no CRC */
+	req.wIndex[0] = sc->sc_ifaces_index[1];
+	req.wIndex[1] = 0;
+	USETW(req.wLength, 0);
+
+	err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req,
+	    NULL, 0, NULL, 1000 /* ms */);
+	if (err) {
+		DPRINTFN(1, "Setting CRC mode to off failed.\n");
+	}
+
+	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+	req.bRequest = UCDC_NCM_SET_NTB_FORMAT;
+	USETW(req.wValue, 0);	/* NTB-16 */
+	req.wIndex[0] = sc->sc_ifaces_index[1];
+	req.wIndex[1] = 0;
+	USETW(req.wLength, 0);
+
+	err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req,
+	    NULL, 0, NULL, 1000 /* ms */);
+	if (err) {
+		DPRINTFN(1, "Setting NTB format to 16-bit failed.\n");
+	}
+
+	return (0);		/* success */
+}
+#endif
+
 static int
 cdce_probe(device_t dev)
 {
@@ -240,31 +448,31 @@ cdce_attach(device_t dev)
 	const struct usb_cdc_union_descriptor *ud;
 	const struct usb_interface_descriptor *id;
 	const struct usb_cdc_ethernet_descriptor *ued;
+	const struct usb_config *pcfg;
 	int error;
 	uint8_t i;
+	uint8_t data_iface_no;
 	char eaddr_str[5 * ETHER_ADDR_LEN];	/* approx */
 
 	sc->sc_flags = USB_GET_DRIVER_INFO(uaa);
+	sc->sc_ue.ue_udev = uaa->device;
 
 	device_set_usb_desc(dev);
 
 	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
 
-	if (sc->sc_flags & CDCE_FLAG_NO_UNION) {
-		sc->sc_ifaces_index[0] = uaa->info.bIfaceIndex;
-		sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex;
-		sc->sc_data_iface_no = 0;	/* not used */
-		goto alloc_transfers;
-	}
 	ud = usbd_find_descriptor
 	    (uaa->device, NULL, uaa->info.bIfaceIndex,
 	    UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_UNION, 0 - 1);
 
-	if ((ud == NULL) || (ud->bLength < sizeof(*ud))) {
-		device_printf(dev, "no union descriptor!\n");
-		goto detach;
+	if ((ud == NULL) || (ud->bLength < sizeof(*ud)) ||
+	    (sc->sc_flags & CDCE_FLAG_NO_UNION)) {
+		DPRINTFN(1, "No union descriptor!\n");
+		sc->sc_ifaces_index[0] = uaa->info.bIfaceIndex;
+		sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex;
+		goto alloc_transfers;
 	}
-	sc->sc_data_iface_no = ud->bSlaveInterface[0];
+	data_iface_no = ud->bSlaveInterface[0];
 
 	for (i = 0;; i++) {
 
@@ -274,8 +482,7 @@ cdce_attach(device_t dev)
 
 			id = usbd_get_interface_descriptor(iface);
 
-			if (id && (id->bInterfaceNumber ==
-			    sc->sc_data_iface_no)) {
+			if (id && (id->bInterfaceNumber == data_iface_no)) {
 				sc->sc_ifaces_index[0] = i;
 				sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex;
 				usbd_set_parent_iface(uaa->device, i, uaa->info.bIfaceIndex);
@@ -312,24 +519,30 @@ cdce_attach(device_t dev)
 
 alloc_transfers:
 
-	for (i = 0; i != 32; i++) {
+	pcfg = cdce_config;	/* Default Configuration */
 
-		error = usbd_set_alt_interface_index
-		    (uaa->device, sc->sc_ifaces_index[0], i);
+	for (i = 0; i != 32; i++) {
 
-		if (error) {
-			device_printf(dev, "no valid alternate "
-			    "setting found!\n");
-			goto detach;
-		}
-		error = usbd_transfer_setup
-		    (uaa->device, sc->sc_ifaces_index,
-		    sc->sc_xfer, cdce_config, CDCE_N_TRANSFER,
-		    sc, &sc->sc_mtx);
+		error = usbd_set_alt_interface_index(uaa->device,
+		    sc->sc_ifaces_index[0], i);
+		if (error)
+			break;
+#if CDCE_HAVE_NCM
+		if ((i == 0) && (cdce_ncm_init(sc) == 0))
+			pcfg = cdce_ncm_config;
+#endif
+		error = usbd_transfer_setup(uaa->device,
+		    sc->sc_ifaces_index, sc->sc_xfer,
+		    pcfg, CDCE_N_TRANSFER, sc, &sc->sc_mtx);
 
-		if (error == 0) {
+		if (error == 0)
 			break;
-		}
+	}
+
+	if (error || (i == 32)) {
+		device_printf(dev, "No valid alternate "
+		    "setting found!\n");
+		goto detach;
 	}
 
 	ued = usbd_find_descriptor
@@ -768,3 +981,328 @@ cdce_handle_request(device_t dev,
 {
 	return (ENXIO);			/* use builtin handler */
 }
+
+#if CDCE_HAVE_NCM
+static uint8_t
+cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index)
+{
+	struct cdce_softc *sc = usbd_xfer_softc(xfer);
+	struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+	struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, index);
+	struct mbuf *m;
+	uint32_t rem;
+	uint32_t offset;
+	uint32_t last_offset;
+	uint32_t n;
+
+	usbd_xfer_set_frame_offset(xfer, index * CDCE_NCM_TX_MAXLEN, index);
+
+	offset = sizeof(sc->sc_ncm.hdr) +
+	    sizeof(sc->sc_ncm.dpt) + sizeof(sc->sc_ncm.dp);
+
+	/* Store last valid offset before alignment */
+	last_offset = offset;
+
+	/* Align offset correctly */
+	offset = sc->sc_ncm.tx_remainder -
+	    ((0UL - offset) & (0UL - sc->sc_ncm.tx_modulus));
+
+	for (n = 0; n != CDCE_NCM_SUBFRAMES_MAX; n++) {
+
+		/* check if end of transmit buffer is reached */
+
+		if (offset >= sc->sc_ncm.tx_max)
+			break;
+
+		/* compute maximum buffer size */
+
+		rem = sc->sc_ncm.tx_max - offset;
+
+		IFQ_DRV_DEQUEUE(&(ifp->if_snd), m);
+
+		if (m == NULL)
+			break;
+
+		if (m->m_pkthdr.len > rem) {
+			if (n == 0) {
+				/* The frame won't fit in our buffer */
+				DPRINTFN(1, "Frame too big to be transmitted!\n");
+				m_freem(m);
+				ifp->if_oerrors++;
+				n--;
+				continue;
+			}
+			/* Wait till next buffer becomes ready */
+			IFQ_DRV_PREPEND(&(ifp->if_snd), m);
+			break;
+		}
+		usbd_m_copy_in(pc, offset, m, 0, m->m_pkthdr.len);
+
+		USETW(sc->sc_ncm.dp[n].wFrameLength, m->m_pkthdr.len);
+		USETW(sc->sc_ncm.dp[n].wFrameIndex, offset);
+
+		/* Update offset */
+		offset += m->m_pkthdr.len;
+
+		/* Store last valid offset before alignment */
+		last_offset = offset;
+
+		/* Align offset correctly */
+		offset = sc->sc_ncm.tx_remainder - 
+		    ((0UL - offset) & (0UL - sc->sc_ncm.tx_modulus));
+
+		/*
+		 * If there's a BPF listener, bounce a copy
+		 * of this frame to him:
+		 */
+		BPF_MTAP(ifp, m);
+
+		/* Free mbuf */
+
+		m_freem(m);
+
+		/* Pre-increment interface counter */
+
+		ifp->if_opackets++;
+	}
+
+	if (n == 0)
+		return (1);
+
+	rem = (sizeof(sc->sc_ncm.dpt) + (4 * n) + 4);
+
+	USETW(sc->sc_ncm.dpt.wLength, rem);
+
+	/* zero the rest of the data pointer entries */
+	for (; n != CDCE_NCM_SUBFRAMES_MAX; n++) {
+		USETW(sc->sc_ncm.dp[n].wFrameLength, 0);
+		USETW(sc->sc_ncm.dp[n].wFrameIndex, 0);
+	}
+
+	/* set frame length */
+	usbd_xfer_set_frame_len(xfer, index, last_offset);
+
+	/* Fill out 16-bit header */
+	sc->sc_ncm.hdr.dwSignature[0] = 'N';
+	sc->sc_ncm.hdr.dwSignature[1] = 'C';
+	sc->sc_ncm.hdr.dwSignature[2] = 'M';
+	sc->sc_ncm.hdr.dwSignature[3] = 'H';
+	USETW(sc->sc_ncm.hdr.wHeaderLength, sizeof(sc->sc_ncm.hdr));
+	USETW(sc->sc_ncm.hdr.wBlockLength, offset);
+	USETW(sc->sc_ncm.hdr.wSequence, sc->sc_ncm.tx_seq);
+	USETW(sc->sc_ncm.hdr.wDptIndex, sizeof(sc->sc_ncm.hdr));
+
+	sc->sc_ncm.tx_seq++;
+
+	/* Fill out 16-bit frame table header */
+	sc->sc_ncm.dpt.dwSignature[0] = 'N';
+	sc->sc_ncm.dpt.dwSignature[1] = 'C';
+	sc->sc_ncm.dpt.dwSignature[2] = 'M';
+	sc->sc_ncm.dpt.dwSignature[3] = 'x';
+	USETW(sc->sc_ncm.dpt.wNextNdpIndex, 0);		/* reserved */
+
+	usbd_copy_in(pc, 0, &(sc->sc_ncm.hdr), sizeof(sc->sc_ncm.hdr));
+	usbd_copy_in(pc, sizeof(sc->sc_ncm.hdr), &(sc->sc_ncm.dpt),
+	    sizeof(sc->sc_ncm.dpt));
+	usbd_copy_in(pc, sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt),
+	    &(sc->sc_ncm.dp), sizeof(sc->sc_ncm.dp));
+	return (0);
+}
+
+static void
+cdce_ncm_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct cdce_softc *sc = usbd_xfer_softc(xfer);
+	struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+	uint16_t x;
+	int actlen;
+	int aframes;
+
+	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_TRANSFERRED:
+
+		usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL);
+
+		DPRINTFN(10, "transfer complete: "
+		    "%u bytes in %u frames\n", actlen, aframes);
+
+	case USB_ST_SETUP:
+		for (x = 0; x != CDCE_NCM_TX_FRAMES_MAX; x++) {
+			if (cdce_ncm_fill_tx_frames(xfer, x))
+				break;
+		}
+
+		if (x != 0) {
+			usbd_xfer_set_frames(xfer, x);
+			usbd_transfer_submit(xfer);
+		}
+		break;
+
+	default:			/* Error */
+		DPRINTFN(10, "Transfer error: %s\n",
+		    usbd_errstr(error));
+
+		/* update error counter */
+		ifp->if_oerrors += 1;
+
+		if (error != USB_ERR_CANCELLED) {
+			/* try to clear stall first */
+			usbd_xfer_set_stall(xfer);
+			usbd_xfer_set_frames(xfer, 0);
+			usbd_transfer_submit(xfer);
+		}
+		break;
+	}
+}
+
+static void
+cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct cdce_softc *sc = usbd_xfer_softc(xfer);
+	struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0);
+	struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+	struct mbuf *m;
+	int sumdata;
+	int sumlen;
+	int actlen;
+	int aframes;
+	int temp;
+	int nframes;
+	int x;
+	int offset;
+
+	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_TRANSFERRED:
+
+		usbd_xfer_status(xfer, &actlen, &sumlen, &aframes, NULL);
+
+		DPRINTFN(1, "received %u bytes in %u frames\n",
+		    actlen, aframes);
+
+		if (actlen < (sizeof(sc->sc_ncm.hdr) +
+		    sizeof(sc->sc_ncm.dpt))) {
+			DPRINTFN(1, "frame too short\n");
+			goto tr_stall;
+		}
+		usbd_copy_out(pc, 0, &(sc->sc_ncm.hdr),
+		    sizeof(sc->sc_ncm.hdr));
+
+		if ((sc->sc_ncm.hdr.dwSignature[0] != 'N') ||
+		    (sc->sc_ncm.hdr.dwSignature[1] != 'C') ||
+		    (sc->sc_ncm.hdr.dwSignature[2] != 'M') ||
+		    (sc->sc_ncm.hdr.dwSignature[3] != 'H')) {
+			DPRINTFN(1, "invalid HDR signature\n");
+			goto tr_stall;
+		}
+		temp = UGETW(sc->sc_ncm.hdr.wBlockLength);
+		if (temp > sumlen) {
+			DPRINTFN(1, "unsupported block length %u/%u\n",
+			    temp, sumlen);
+			goto tr_stall;
+		}
+		temp = UGETW(sc->sc_ncm.hdr.wDptIndex);
+		if ((temp + sizeof(sc->sc_ncm.dpt)) > actlen) {
+			DPRINTFN(1, "invalid DPT index\n");
+			goto tr_stall;
+		}
+		usbd_copy_out(pc, temp, &(sc->sc_ncm.dpt),
+		    sizeof(sc->sc_ncm.dpt));
+
+		if ((sc->sc_ncm.dpt.dwSignature[0] != 'N') ||
+		    (sc->sc_ncm.dpt.dwSignature[1] != 'C') ||
+		    (sc->sc_ncm.dpt.dwSignature[2] != 'M') ||
+		    (sc->sc_ncm.dpt.dwSignature[3] != 'x')) {
+			DPRINTFN(1, "invalid DPT signature\n");
+			goto tr_stall;
+		}
+		nframes = UGETW(sc->sc_ncm.dpt.wLength) / 4;
+
+		/* Subtract size of header and last zero padded entry */
+		if (nframes >= (2 + 1))
+			nframes -= (2 + 1);
+		else
+			nframes = 0;
+
+		DPRINTFN(1, "nframes = %u\n", nframes);
+
+		temp += sizeof(sc->sc_ncm.dpt);
+
+		if ((temp + (4 * nframes)) > actlen)
+			goto tr_stall;
+
+		if (nframes > CDCE_NCM_SUBFRAMES_MAX) {
+			DPRINTFN(1, "Truncating number of frames from %u to %u\n",
+			    nframes, CDCE_NCM_SUBFRAMES_MAX);
+			nframes = CDCE_NCM_SUBFRAMES_MAX;
+		}
+		usbd_copy_out(pc, temp, &(sc->sc_ncm.dp), (4 * nframes));
+
+		sumdata = 0;
+
+		for (x = 0; x != nframes; x++) {
+
+			offset = UGETW(sc->sc_ncm.dp[x].wFrameIndex);
+			temp = UGETW(sc->sc_ncm.dp[x].wFrameLength);
+			if ((offset + temp) > actlen) {
+				DPRINTFN(1, "invalid frame detected (ignored)\n");
+				m = NULL;
+
+			} else if (temp >= sizeof(struct ether_header)) {
+				/*
+				 * allocate a suitable memory buffer, if
+				 * possible
+				 */
+				if (temp > (MCLBYTES - ETHER_ALIGN)) {
+					m = NULL;
+					continue;
+				} if (temp > (MHLEN - ETHER_ALIGN)) {
+					m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+				} else {
+					m = m_gethdr(M_DONTWAIT, MT_DATA);
+				}
+			} else {
+				m = NULL;	/* dump it */
+			}
+
+			DPRINTFN(16, "frame %u, offset = %u, length = %u \n",
+			    x, offset, temp);
+
+			/* check if we have a buffer */
+			if (m) {
+				m_adj(m, ETHER_ALIGN);
+
+				usbd_copy_out(pc, offset, m->m_data, temp);
+
+				/* enqueue */
+				uether_rxmbuf(&sc->sc_ue, m, temp);
+
+				sumdata += temp;
+			} else {
+				ifp->if_ierrors++;
+			}
+		}
+
+		DPRINTFN(1, "Efficiency: %u/%u bytes\n", sumdata, actlen);
+
+	case USB_ST_SETUP:
+		usbd_xfer_set_frame_len(xfer, 0, sc->sc_ncm.rx_max);
+		usbd_xfer_set_frames(xfer, 1);
+		usbd_transfer_submit(xfer);
+		uether_rxflush(&sc->sc_ue);	/* must be last */
+		break;
+
+	default:			/* Error */
+		DPRINTFN(1, "error = %s\n",
+		    usbd_errstr(error));
+
+		if (error != USB_ERR_CANCELLED) {
+tr_stall:
+			/* try to clear stall first */
+			usbd_xfer_set_stall(xfer);
+			usbd_xfer_set_frames(xfer, 0);
+			usbd_transfer_submit(xfer);
+		}
+		break;
+	}
+}
+#endif

Modified: stable/8/sys/dev/usb/net/if_cdcereg.h
==============================================================================
--- stable/8/sys/dev/usb/net/if_cdcereg.h	Thu Oct 29 23:18:59 2009	(r198647)
+++ stable/8/sys/dev/usb/net/if_cdcereg.h	Thu Oct 29 23:19:41 2009	(r198648)
@@ -38,6 +38,18 @@
 #define	CDCE_FRAMES_MAX	8		/* units */
 #define	CDCE_IND_SIZE_MAX 32            /* bytes */
 
+#define	CDCE_NCM_TX_MAXLEN 2048UL	/* bytes */
+#define	CDCE_NCM_TX_FRAMES_MAX 8	/* units */
+
+#define	CDCE_NCM_RX_MAXLEN (1UL << 14)	/* bytes */
+#define	CDCE_NCM_RX_FRAMES_MAX 1	/* units */
+
+#define	CDCE_NCM_SUBFRAMES_MAX 32	/* units */
+
+#ifndef CDCE_HAVE_NCM
+#define	CDCE_HAVE_NCM 1
+#endif
+
 enum {
 	CDCE_BULK_RX,
 	CDCE_BULK_TX,
@@ -46,9 +58,24 @@ enum {
 	CDCE_N_TRANSFER,
 };
 
+struct cdce_ncm {
+	struct usb_ncm16_hdr hdr;
+	struct usb_ncm16_dpt dpt;
+	struct usb_ncm16_dp dp[CDCE_NCM_SUBFRAMES_MAX];
+	uint32_t rx_max;
+	uint32_t tx_max;
+	uint16_t tx_remainder;
+	uint16_t tx_modulus;
+	uint16_t tx_struct_align;
+	uint16_t tx_seq;
+};
+
 struct cdce_softc {
 	struct usb_ether	sc_ue;
 	struct mtx		sc_mtx;
+#if CDCE_HAVE_NCM
+	struct cdce_ncm		sc_ncm;
+#endif
 	struct usb_xfer	*sc_xfer[CDCE_N_TRANSFER];
 	struct mbuf		*sc_rx_buf[CDCE_FRAMES_MAX];
 	struct mbuf		*sc_tx_buf[CDCE_FRAMES_MAX];
@@ -59,7 +86,6 @@ struct cdce_softc {
 #define	CDCE_FLAG_RX_DATA	0x0010
 
 	uint8_t sc_eaddr_str_index;
-	uint8_t	sc_data_iface_no;
 	uint8_t	sc_ifaces_index[2];
 };
 

Modified: stable/8/sys/dev/usb/usb.h
==============================================================================
--- stable/8/sys/dev/usb/usb.h	Thu Oct 29 23:18:59 2009	(r198647)
+++ stable/8/sys/dev/usb/usb.h	Thu Oct 29 23:19:41 2009	(r198648)
@@ -424,9 +424,9 @@ typedef struct usb_interface_assoc_descr
 #define	UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10
 #define	UISUBCLASS_OBEX 11
 #define	UISUBCLASS_ETHERNET_EMULATION_MODEL 12
+#define	UISUBCLASS_NETWORK_CONTROL_MODEL 13
 
 #define	UIPROTO_CDC_AT			1
-#define	UIPROTO_CDC_ETH_512X4 0x76	/* FreeBSD specific */
 
 #define	UICLASS_HID		0x03
 #define	UISUBCLASS_BOOT		1
@@ -461,7 +461,7 @@ typedef struct usb_interface_assoc_descr
 #define	UIPROTO_HSHUBMTT	1
 
 #define	UICLASS_CDC_DATA	0x0a
-#define	UISUBCLASS_DATA		0
+#define	UISUBCLASS_DATA		0x00
 #define	UIPROTO_DATA_ISDNBRI		0x30	/* Physical iface */
 #define	UIPROTO_DATA_HDLC		0x31	/* HDLC */
 #define	UIPROTO_DATA_TRANSPARENT	0x32	/* Transparent */
@@ -475,6 +475,7 @@ typedef struct usb_interface_assoc_descr
 #define	UIPROTO_DATA_HOST_BASED		0xfd	/* Host based driver */
 #define	UIPROTO_DATA_PUF		0xfe	/* see Prot. Unit Func. Desc. */
 #define	UIPROTO_DATA_VENDOR		0xff	/* Vendor specific */
+#define	UIPROTO_DATA_NCM		0x01	/* Network Control Model */
 
 #define	UICLASS_SMARTCARD	0x0b
 #define	UICLASS_FIRM_UPD	0x0c

Modified: stable/8/sys/dev/usb/usb_cdc.h
==============================================================================
--- stable/8/sys/dev/usb/usb_cdc.h	Thu Oct 29 23:18:59 2009	(r198647)
+++ stable/8/sys/dev/usb/usb_cdc.h	Thu Oct 29 23:19:41 2009	(r198648)
@@ -188,4 +188,107 @@ struct usb_cdc_notification {
 #define	UCDC_MDM_PARITY_ERR		0x20
 #define	UCDC_MDM_OVERRUN_ERR		0x40
 
+/*
+ * Network Control Model, NCM16 + NCM32, protocol definitions
+ */
+struct usb_ncm16_hdr {
+	uDWord	dwSignature;
+	uWord	wHeaderLength;
+	uWord	wSequence;
+	uWord	wBlockLength;
+	uWord	wDptIndex;
+} __packed;
+
+struct usb_ncm16_dp {
+	uWord	wFrameIndex;
+	uWord	wFrameLength;
+} __packed;
+
+struct usb_ncm16_dpt {
+	uDWord	dwSignature;
+	uWord	wLength;
+	uWord	wNextNdpIndex;
+	struct usb_ncm16_dp dp[0];
+} __packed;
+
+struct usb_ncm32_hdr {
+	uDWord	dwSignature;
+	uWord	wHeaderLength;
+	uWord	wSequence;
+	uDWord	dwBlockLength;
+	uDWord	dwDptIndex;
+} __packed;
+
+struct usb_ncm32_dp {
+	uDWord	dwFrameIndex;
+	uDWord	dwFrameLength;
+} __packed;
+
+struct usb_ncm32_dpt {
+	uDWord	dwSignature;
+	uWord	wLength;
+	uWord	wReserved6;
+	uDWord	dwNextNdpIndex;
+	uDWord	dwReserved12;
+	struct usb_ncm32_dp dp[0];
+} __packed;
+
+/* Communications interface class specific descriptors */
+
+#define	UCDC_NCM_FUNC_DESC_SUBTYPE	0x1A
+
+struct usb_ncm_func_descriptor {
+	uByte	bLength;
+	uByte	bDescriptorType;
+	uByte	bDescriptorSubtype;
+	uByte	bcdNcmVersion[2];
+	uByte	bmNetworkCapabilities;
+#define	UCDC_NCM_CAP_FILTER	0x01
+#define	UCDC_NCM_CAP_MAC_ADDR	0x02
+#define	UCDC_NCM_CAP_ENCAP	0x04
+#define	UCDC_NCM_CAP_MAX_DATA	0x08
+#define	UCDC_NCM_CAP_CRCMODE	0x10
+} __packed;
+
+/* Communications interface specific class request codes */
+
+#define	UCDC_NCM_SET_ETHERNET_MULTICAST_FILTERS			0x40
+#define	UCDC_NCM_SET_ETHERNET_POWER_MGMT_PATTERN_FILTER		0x41
+#define	UCDC_NCM_GET_ETHERNET_POWER_MGMT_PATTERN_FILTER		0x42
+#define	UCDC_NCM_SET_ETHERNET_PACKET_FILTER			0x43
+#define	UCDC_NCM_GET_ETHERNET_STATISTIC				0x44
+#define	UCDC_NCM_GET_NTB_PARAMETERS				0x80
+#define	UCDC_NCM_GET_NET_ADDRESS				0x81
+#define	UCDC_NCM_SET_NET_ADDRESS				0x82
+#define	UCDC_NCM_GET_NTB_FORMAT					0x83
+#define	UCDC_NCM_SET_NTB_FORMAT					0x84
+#define	UCDC_NCM_GET_NTB_INPUT_SIZE				0x85
+#define	UCDC_NCM_SET_NTB_INPUT_SIZE				0x86
+#define	UCDC_NCM_GET_MAX_DATAGRAM_SIZE				0x87
+#define	UCDC_NCM_SET_MAX_DATAGRAM_SIZE				0x88
+#define	UCDC_NCM_GET_CRC_MODE					0x89
+#define	UCDC_NCM_SET_CRC_MODE					0x8A
+
+struct usb_ncm_parameters {
+	uWord	wLength;
+	uWord	bmNtbFormatsSupported;
+#define	UCDC_NCM_FORMAT_NTB16	0x0001
+#define	UCDC_NCM_FORMAT_NTB32	0x0002
+	uDWord	dwNtbInMaxSize;
+	uWord	wNdpInDivisor;
+	uWord	wNdpInPayloadRemainder;
+	uWord	wNdpInAlignment;
+	uWord	wReserved14;
+	uDWord	dwNtbOutMaxSize;
+	uWord	wNdpOutDivisor;
+	uWord	wNdpOutPayloadRemainder;
+	uWord	wNdpOutAlignment;
+	uWord	wReserved26;
+} __packed;
+
+/* Communications interface specific class notification codes */
+#define	UCDC_NCM_NOTIF_NETWORK_CONNECTION	0x00
+#define	UCDC_NCM_NOTIF_RESPONSE_AVAILABLE	0x01
+#define	UCDC_NCM_NOTIF_CONNECTION_SPEED_CHANGE	0x2A
+
 #endif					/* _USB_CDC_H_ */

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:20:15 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 91C1C106568F;
	Thu, 29 Oct 2009 23:20:15 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 63E238FC14;
	Thu, 29 Oct 2009 23:20:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNKFnI014825;
	Thu, 29 Oct 2009 23:20:15 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNKF5A014823;
	Thu, 29 Oct 2009 23:20:15 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292320.n9TNKF5A014823@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:20:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198649 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:20:15 -0000

Author: thompsa
Date: Thu Oct 29 23:20:15 2009
New Revision: 198649
URL: http://svn.freebsd.org/changeset/base/198649

Log:
  MFC r197564
  
   Add new usbdev entries for Marvell, FTDI, Option and Western.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/usbdevs
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/usbdevs
==============================================================================
--- stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:19:41 2009	(r198648)
+++ stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:20:15 2009	(r198649)
@@ -659,6 +659,7 @@ vendor 3COM2		0x6891	3Com
 vendor INTEL		0x8086	Intel
 vendor SITECOM2		0x9016	Sitecom
 vendor MOSCHIP		0x9710	MosChip Semiconductor
+vendor MARVELL		0x9e88	Marvell Technology Group Ltd.
 vendor 3COM3		0xa727	3Com
 vendor HP2		0xf003	Hewlett Packard
 vendor USRP		0xfffe	GNU Radio USRP
@@ -1336,6 +1337,9 @@ product FTDI CFA_633		0xfc0b	Crystalfont
 product FTDI CFA_631		0xfc0c	Crystalfontz CFA-631 USB LCD
 product FTDI CFA_635		0xfc0d	Crystalfontz CFA-635 USB LCD
 product FTDI SEMC_DSS20		0xfc82	SEMC DSS-20 SyncStation
+/* Commerzielle und Technische Informationssysteme GmbH products */
+product FTDI CTI_USB_NANO_485	0xf60b	CTI USB-Nano 485
+product FTDI CTI_USB_MINI_485	0xf608	CTI USB-Mini 485
 
 /* Fuji photo products */
 product FUJIPHOTO MASS0100	0x0100	Mass Storage
@@ -1691,6 +1695,9 @@ product LUWEN EASYDISK		0x0005	EasyDisc
 /* Macally products */
 product MACALLY MOUSE1		0x0101	mouse
 
+/* Marvell Technology Group, Ltd. products */
+product MARVELL SHEEVAPLUG	0x9e8f	SheevaPlug serial interface
+
 /* MCT Corp. */
 product MCT HUB0100		0x0100	Hub
 product MCT DU_H3SP_USB232	0x0200	D-Link DU-H3SP USB BAY Hub
@@ -1940,6 +1947,8 @@ product OPTION GTICON322	0xd033	GlobeTro
 product OPTION GTMAX36		0x6701	GlobeTrotter Max 3.6 Modem
 product OPTION GTHSDPA		0x6971	GlobeTrotter HSDPA
 product OPTION GTMAXHSUPA	0x7001	GlobeTrotter HSUPA
+product OPTION GTMAXHSUPAE	0x6901	GlobeTrotter HSUPA PCIe
+product OPTION GTMAX380HSUPAE	0x7211	GlobeTrotter 380HSUPA PCIe
 
 /* OQO */
 product OQO WIFI01		0x0002	model 01 WiFi interface
@@ -2504,6 +2513,7 @@ product WESTERN COMBO		0x0200	Firewire U
 product WESTERN EXTHDD		0x0400	External HDD
 product WESTERN HUB		0x0500	USB HUB
 product WESTERN MYBOOK		0x0901	MyBook External HDD
+product WESTERN MYPASSWORD	0x0704	MyPassword External HDD
 
 /* Windbond Electronics */
 product WINBOND UH104		0x5518	4-port USB Hub

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:20:48 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3F8191065754;
	Thu, 29 Oct 2009 23:20:48 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2AF5F8FC27;
	Thu, 29 Oct 2009 23:20:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNKlmY014881;
	Thu, 29 Oct 2009 23:20:47 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNKlGc014879;
	Thu, 29 Oct 2009 23:20:47 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292320.n9TNKlGc014879@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:20:47 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198650 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/storage dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:20:48 -0000

Author: thompsa
Date: Thu Oct 29 23:20:47 2009
New Revision: 198650
URL: http://svn.freebsd.org/changeset/base/198650

Log:
  MFC r197565
  
   - Remove SAMSUNG_YP_U2 now that it is in the cam layer
   - Add quirk from Tobias Grosser for Western Mypassword

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/storage/umass.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/storage/umass.c
==============================================================================
--- stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:20:15 2009	(r198649)
+++ stable/8/sys/dev/usb/storage/umass.c	Thu Oct 29 23:20:47 2009	(r198650)
@@ -750,10 +750,6 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		IGNORE_RESIDUE | NO_START_STOP
 	},
-	{USB_VENDOR_SAMSUNG, USB_PRODUCT_SAMSUNG_YP_U2, RID_WILDCARD,
-		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
-		SHUTTLE_INIT | NO_GETMAXLUN
-	},
 	{USB_VENDOR_SAMSUNG_TECHWIN, USB_PRODUCT_SAMSUNG_TECHWIN_DIGIMAX_410, RID_WILDCARD,
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_INQUIRY
@@ -950,6 +946,10 @@ static const struct umass_devdescr umass
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_INQUIRY_EVPD
 	},
+	{USB_VENDOR_WESTERN, USB_PRODUCT_WESTERN_MYPASSWORD, RID_WILDCARD,
+		UMASS_PROTO_DEFAULT,
+		FORCE_SHORT_INQUIRY
+	},
 	{USB_VENDOR_WINMAXGROUP, USB_PRODUCT_WINMAXGROUP_FLASH64MC, RID_WILDCARD,
 		UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
 		NO_INQUIRY

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:21:21 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5495610656A3;
	Thu, 29 Oct 2009 23:21:21 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 400458FC16;
	Thu, 29 Oct 2009 23:21:21 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNLLXs014943;
	Thu, 29 Oct 2009 23:21:21 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNLL0Z014941;
	Thu, 29 Oct 2009 23:21:21 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292321.n9TNLL0Z014941@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:21:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198651 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:21:21 -0000

Author: thompsa
Date: Thu Oct 29 23:21:20 2009
New Revision: 198651
URL: http://svn.freebsd.org/changeset/base/198651

Log:
  MFC r197566
  
   Increase the rx buffer size to 16384 bytes, this increases RX performance from
   50Mbps to 220Mbps on PLANEX GU-1000T.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_axe.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_axe.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_axe.c	Thu Oct 29 23:20:47 2009	(r198650)
+++ stable/8/sys/dev/usb/net/if_axe.c	Thu Oct 29 23:21:20 2009	(r198651)
@@ -205,10 +205,7 @@ static const struct usb_config axe_confi
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
-#if (MCLBYTES < 2048)
-#error "(MCLBYTES < 2048)"
-#endif
-		.bufsize = MCLBYTES,
+		.bufsize = 16384,	/* bytes */
 		.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
 		.callback = axe_bulk_read_callback,
 		.timeout = 0,	/* no timeout */
@@ -777,7 +774,7 @@ axe_bulk_read_callback(struct usb_xfer *
 	struct ifnet *ifp = uether_getifp(ue);
 	struct axe_sframe_hdr hdr;
 	struct usb_page_cache *pc;
-	int err, pos, len, adjust;
+	int err, pos, len;
 	int actlen;
 
 	usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
@@ -785,50 +782,42 @@ axe_bulk_read_callback(struct usb_xfer *
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
 		pos = 0;
+		len = 0;
+		err = 0;
+
 		pc = usbd_xfer_get_frame(xfer, 0);
-		while (1) {
-			if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
-				if (actlen < sizeof(hdr)) {
+		if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
+			while (pos < actlen) {
+				if ((pos + sizeof(hdr)) > actlen) {
 					/* too little data */
+					err = EINVAL;
 					break;
 				}
 				usbd_copy_out(pc, pos, &hdr, sizeof(hdr));
 
 				if ((hdr.len ^ hdr.ilen) != 0xFFFF) {
 					/* we lost sync */
+					err = EINVAL;
 					break;
 				}
-				actlen -= sizeof(hdr);
 				pos += sizeof(hdr);
 
 				len = le16toh(hdr.len);
-				if (len > actlen) {
+				if ((pos + len) > actlen) {
 					/* invalid length */
+					err = EINVAL;
 					break;
 				}
-				adjust = (len & 1);
-
-			} else {
-				len = actlen;
-				adjust = 0;
-			}
-			err = uether_rxbuf(ue, pc, pos, len);
-			if (err)
-				break;
-
-			pos += len;
-			actlen -= len;
+				err = uether_rxbuf(ue, pc, pos, len);
 
-			if (actlen <= adjust) {
-				/* we are finished */
-				goto tr_setup;
+				pos += len + (len % 2);
 			}
-			pos += adjust;
-			actlen -= adjust;
+		} else {
+			err = uether_rxbuf(ue, pc, 0, actlen);
 		}
 
-		/* count an error */
-		ifp->if_ierrors++;
+		if (err != 0)
+			ifp->if_ierrors++;
 
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
@@ -1011,7 +1000,15 @@ axe_init(struct usb_ether *ue)
 	/* Enable receiver, set RX mode */
 	rxmode = (AXE_RXCMD_MULTICAST | AXE_RXCMD_ENABLE);
 	if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) {
+#if 0
 		rxmode |= AXE_178_RXCMD_MFB_2048;	/* chip default */
+#else
+		/*
+		 * Default Rx buffer size is too small to get
+		 * maximum performance.
+		 */
+		rxmode |= AXE_178_RXCMD_MFB_16384;
+#endif
 	} else {
 		rxmode |= AXE_172_RXCMD_UNICAST;
 	}

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:21:52 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8640B10656B0;
	Thu, 29 Oct 2009 23:21:52 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 71B988FC1A;
	Thu, 29 Oct 2009 23:21:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNLqsN014999;
	Thu, 29 Oct 2009 23:21:52 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNLqBR014997;
	Thu, 29 Oct 2009 23:21:52 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292321.n9TNLqBR014997@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:21:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198652 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:21:52 -0000

Author: thompsa
Date: Thu Oct 29 23:21:52 2009
New Revision: 198652
URL: http://svn.freebsd.org/changeset/base/198652

Log:
  MFC r197567
  
   Allow setting of MAC address for AXE based ethernet adapters.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_axe.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_axe.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_axe.c	Thu Oct 29 23:21:20 2009	(r198651)
+++ stable/8/sys/dev/usb/net/if_axe.c	Thu Oct 29 23:21:52 2009	(r198652)
@@ -982,10 +982,11 @@ axe_init(struct usb_ether *ue)
 	/* Cancel pending I/O */
 	axe_stop(ue);
 
-#ifdef notdef
-	/* Set MAC address */
-	axe_mac(sc, IF_LLADDR(ifp), 1);
-#endif
+	/* Set MAC address. */
+	if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772))
+		axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
+	else
+		axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
 
 	/* Set transmitter IPG values */
 	if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) {

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:22:23 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BA8DD10656A6;
	Thu, 29 Oct 2009 23:22:23 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A60898FC18;
	Thu, 29 Oct 2009 23:22:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNMNMF015091;
	Thu, 29 Oct 2009 23:22:23 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNMNsK015089;
	Thu, 29 Oct 2009 23:22:23 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292322.n9TNMNsK015089@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:22:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198653 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:22:23 -0000

Author: thompsa
Date: Thu Oct 29 23:22:23 2009
New Revision: 198653
URL: http://svn.freebsd.org/changeset/base/198653

Log:
  MFC r197568
  
   add more device IDs

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/u3g.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/u3g.c
==============================================================================
--- stable/8/sys/dev/usb/serial/u3g.c	Thu Oct 29 23:21:52 2009	(r198652)
+++ stable/8/sys/dev/usb/serial/u3g.c	Thu Oct 29 23:22:23 2009	(r198653)
@@ -180,6 +180,8 @@ static const struct usb_device_id u3g_de
 	U3G_DEV(OPTION, GTMAX36, 0),
 	U3G_DEV(OPTION, GTHSDPA, 0),
 	U3G_DEV(OPTION, GTMAXHSUPA, 0),
+	U3G_DEV(OPTION, GTMAXHSUPAE, 0),
+	U3G_DEV(OPTION, GTMAX380HSUPAE, 0),
 	U3G_DEV(OPTION, VODAFONEMC3G, 0),
 	/* OEM: Qualcomm, Inc. */
 	U3G_DEV(QUALCOMMINC, ZTE_STOR, U3GFL_SCSI_EJECT),
@@ -204,6 +206,7 @@ static const struct usb_device_id u3g_de
 	U3G_DEV(NOVATEL, X950D, 0),
 	U3G_DEV(NOVATEL, XU870, 0),
 	U3G_DEV(NOVATEL, ZEROCD, U3GFL_SCSI_EJECT),
+	U3G_DEV(NOVATEL, U760, U3GFL_SCSI_EJECT),
 	U3G_DEV(DELL, U740, 0),
 	/* OEM: Merlin */
 	U3G_DEV(MERLIN, V620, 0),

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:22:54 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B21591065694;
	Thu, 29 Oct 2009 23:22:54 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9DA8F8FC0C;
	Thu, 29 Oct 2009 23:22:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNMsd9015179;
	Thu, 29 Oct 2009 23:22:54 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNMsM1015177;
	Thu, 29 Oct 2009 23:22:54 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292322.n9TNMsM1015177@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:22:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198654 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/quirk dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:22:54 -0000

Author: thompsa
Date: Thu Oct 29 23:22:54 2009
New Revision: 198654
URL: http://svn.freebsd.org/changeset/base/198654

Log:
  MFC r197569
  
   Add a config number quirk for the ELSA_MODEM1

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/quirk/usb_quirk.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- stable/8/sys/dev/usb/quirk/usb_quirk.c	Thu Oct 29 23:22:23 2009	(r198653)
+++ stable/8/sys/dev/usb/quirk/usb_quirk.c	Thu Oct 29 23:22:54 2009	(r198654)
@@ -94,6 +94,7 @@ static struct usb_quirk_entry usb_quirks
 	{USB_QUIRK_ENTRY(USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, 0x009, UQ_AU_NO_FRAC, UQ_NONE)},
 	{USB_QUIRK_ENTRY(USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE, 0x100, 0x100, UQ_AU_INP_ASYNC, UQ_NONE)},
 	{USB_QUIRK_ENTRY(USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_UN53B, 0x0000, 0xFFFF, UQ_NO_STRINGS, UQ_NONE)},
+	{USB_QUIRK_ENTRY(USB_VENDOR_ELSA, USB_PRODUCT_ELSA_MODEM1, 0x0000, 0xFFFF, UQ_CFG_INDEX_1, UQ_NONE)},
 
 	/*
 	 * XXX The following quirks should have a more specific revision

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:23:34 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BFD881065694;
	Thu, 29 Oct 2009 23:23:34 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AA0658FC16;
	Thu, 29 Oct 2009 23:23:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNNYdB015298;
	Thu, 29 Oct 2009 23:23:34 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNNYvk015280;
	Thu, 29 Oct 2009 23:23:34 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292323.n9TNNYvk015280@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:23:34 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198655 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:23:34 -0000

Author: thompsa
Date: Thu Oct 29 23:23:34 2009
New Revision: 198655
URL: http://svn.freebsd.org/changeset/base/198655

Log:
  MFC r197570
  
   Add experimental support for usb serial console and polled mode during DDB.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/uark.c
  stable/8/sys/dev/usb/serial/ubsa.c
  stable/8/sys/dev/usb/serial/ubser.c
  stable/8/sys/dev/usb/serial/uchcom.c
  stable/8/sys/dev/usb/serial/ucycom.c
  stable/8/sys/dev/usb/serial/ufoma.c
  stable/8/sys/dev/usb/serial/uftdi.c
  stable/8/sys/dev/usb/serial/ugensa.c
  stable/8/sys/dev/usb/serial/uipaq.c
  stable/8/sys/dev/usb/serial/umct.c
  stable/8/sys/dev/usb/serial/umodem.c
  stable/8/sys/dev/usb/serial/umoscom.c
  stable/8/sys/dev/usb/serial/uplcom.c
  stable/8/sys/dev/usb/serial/usb_serial.c
  stable/8/sys/dev/usb/serial/usb_serial.h
  stable/8/sys/dev/usb/serial/uslcom.c
  stable/8/sys/dev/usb/serial/uvscom.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/uark.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uark.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uark.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -114,6 +114,7 @@ static void	uark_cfg_get_status(struct u
 		    uint8_t *);
 static void	uark_cfg_set_break(struct ucom_softc *, uint8_t);
 static void	uark_cfg_write(struct uark_softc *, uint16_t, uint16_t);
+static void	uark_poll(struct ucom_softc *ucom);
 
 static const struct usb_config
 	uark_xfer_config[UARK_N_TRANSFER] = {
@@ -146,6 +147,7 @@ static const struct ucom_callback uark_c
 	.ucom_stop_read = &uark_stop_read,
 	.ucom_start_write = &uark_start_write,
 	.ucom_stop_write = &uark_stop_write,
+	.ucom_poll = &uark_poll,
 };
 
 static device_method_t uark_methods[] = {
@@ -431,3 +433,10 @@ uark_cfg_write(struct uark_softc *sc, ui
 		    "(ignored)\n", usbd_errstr(err));
 	}
 }
+
+static void
+uark_poll(struct ucom_softc *ucom)
+{
+	struct uark_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UARK_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/ubsa.c
==============================================================================
--- stable/8/sys/dev/usb/serial/ubsa.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/ubsa.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -194,6 +194,7 @@ static void	ubsa_start_write(struct ucom
 static void	ubsa_stop_write(struct ucom_softc *);
 static void	ubsa_cfg_get_status(struct ucom_softc *, uint8_t *,
 		    uint8_t *);
+static void	ubsa_poll(struct ucom_softc *ucom);
 
 static const struct usb_config ubsa_config[UBSA_N_TRANSFER] = {
 
@@ -236,6 +237,7 @@ static const struct ucom_callback ubsa_c
 	.ucom_stop_read = &ubsa_stop_read,
 	.ucom_start_write = &ubsa_start_write,
 	.ucom_stop_write = &ubsa_stop_write,
+	.ucom_poll = &ubsa_poll,
 };
 
 static const struct usb_device_id ubsa_devs[] = {
@@ -659,3 +661,11 @@ tr_setup:
 
 	}
 }
+
+static void
+ubsa_poll(struct ucom_softc *ucom)
+{
+	struct ubsa_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UBSA_N_TRANSFER);
+
+}

Modified: stable/8/sys/dev/usb/serial/ubser.c
==============================================================================
--- stable/8/sys/dev/usb/serial/ubser.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/ubser.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -163,6 +163,7 @@ static void	ubser_start_read(struct ucom
 static void	ubser_stop_read(struct ucom_softc *);
 static void	ubser_start_write(struct ucom_softc *);
 static void	ubser_stop_write(struct ucom_softc *);
+static void	ubser_poll(struct ucom_softc *ucom);
 
 static const struct usb_config ubser_config[UBSER_N_TRANSFER] = {
 
@@ -193,6 +194,7 @@ static const struct ucom_callback ubser_
 	.ucom_stop_read = &ubser_stop_read,
 	.ucom_start_write = &ubser_start_write,
 	.ucom_stop_write = &ubser_stop_write,
+	.ucom_poll = &ubser_poll,
 };
 
 static device_method_t ubser_methods[] = {
@@ -535,3 +537,10 @@ ubser_stop_write(struct ucom_softc *ucom
 
 	usbd_transfer_stop(sc->sc_xfer[UBSER_BULK_DT_WR]);
 }
+
+static void
+ubser_poll(struct ucom_softc *ucom)
+{
+	struct ubser_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UBSER_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/uchcom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uchcom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uchcom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -230,6 +230,7 @@ static void	uchcom_set_dte_rate(struct u
 static void	uchcom_set_line_control(struct uchcom_softc *, tcflag_t);
 static void	uchcom_clear_chip(struct uchcom_softc *);
 static void	uchcom_reset_chip(struct uchcom_softc *);
+static void	uchcom_poll(struct ucom_softc *ucom);
 
 static device_probe_t uchcom_probe;
 static device_attach_t uchcom_attach;
@@ -280,6 +281,7 @@ static struct ucom_callback uchcom_callb
 	.ucom_stop_read = &uchcom_stop_read,
 	.ucom_start_write = &uchcom_start_write,
 	.ucom_stop_write = &uchcom_stop_write,
+	.ucom_poll = &uchcom_poll,
 };
 
 /* ----------------------------------------------------------------------
@@ -888,6 +890,13 @@ tr_setup:
 	}
 }
 
+static void
+uchcom_poll(struct ucom_softc *ucom)
+{
+	struct uchcom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UCHCOM_N_TRANSFER);
+}
+
 static device_method_t uchcom_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe, uchcom_probe),

Modified: stable/8/sys/dev/usb/serial/ucycom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/ucycom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/ucycom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -124,6 +124,7 @@ static void	ucycom_stop_write(struct uco
 static void	ucycom_cfg_write(struct ucycom_softc *, uint32_t, uint8_t);
 static int	ucycom_pre_param(struct ucom_softc *, struct termios *);
 static void	ucycom_cfg_param(struct ucom_softc *, struct termios *);
+static void	ucycom_poll(struct ucom_softc *ucom);
 
 static const struct usb_config ucycom_config[UCYCOM_N_TRANSFER] = {
 
@@ -154,6 +155,7 @@ static const struct ucom_callback ucycom
 	.ucom_stop_read = &ucycom_stop_read,
 	.ucom_start_write = &ucycom_start_write,
 	.ucom_stop_write = &ucycom_stop_write,
+	.ucom_poll = &ucycom_poll,
 };
 
 static device_method_t ucycom_methods[] = {
@@ -578,3 +580,10 @@ tr_setup:
 
 	}
 }
+
+static void
+ucycom_poll(struct ucom_softc *ucom)
+{
+	struct ucycom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UCYCOM_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/ufoma.c
==============================================================================
--- stable/8/sys/dev/usb/serial/ufoma.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/ufoma.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -230,13 +230,13 @@ static void	ufoma_start_read(struct ucom
 static void	ufoma_stop_read(struct ucom_softc *);
 static void	ufoma_start_write(struct ucom_softc *);
 static void	ufoma_stop_write(struct ucom_softc *);
+static void	ufoma_poll(struct ucom_softc *ucom);
 
 /*sysctl stuff*/
 static int ufoma_sysctl_support(SYSCTL_HANDLER_ARGS);
 static int ufoma_sysctl_current(SYSCTL_HANDLER_ARGS);
 static int ufoma_sysctl_open(SYSCTL_HANDLER_ARGS);
 
-
 static const struct usb_config
 	ufoma_ctrl_config[UFOMA_CTRL_ENDPT_MAX] = {
 
@@ -304,6 +304,7 @@ static const struct ucom_callback ufoma_
 	.ucom_stop_read = &ufoma_stop_read,
 	.ucom_start_write = &ufoma_start_write,
 	.ucom_stop_write = &ufoma_stop_write,
+	.ucom_poll = &ufoma_poll,
 };
 
 static device_method_t ufoma_methods[] = {
@@ -1241,3 +1242,11 @@ static int ufoma_sysctl_open(SYSCTL_HAND
 	
 	return EINVAL;
 }
+
+static void
+ufoma_poll(struct ucom_softc *ucom)
+{
+	struct ufoma_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_ctrl_xfer, UFOMA_CTRL_ENDPT_MAX);
+	usbd_transfer_poll(sc->sc_bulk_xfer, UFOMA_BULK_ENDPT_MAX);
+}

Modified: stable/8/sys/dev/usb/serial/uftdi.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uftdi.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uftdi.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -156,6 +156,7 @@ static void	uftdi_stop_read(struct ucom_
 static void	uftdi_start_write(struct ucom_softc *);
 static void	uftdi_stop_write(struct ucom_softc *);
 static uint8_t	uftdi_8u232am_getrate(uint32_t, uint16_t *);
+static void	uftdi_poll(struct ucom_softc *ucom);
 
 static const struct usb_config uftdi_config[UFTDI_N_TRANSFER] = {
 
@@ -190,6 +191,7 @@ static const struct ucom_callback uftdi_
 	.ucom_stop_read = &uftdi_stop_read,
 	.ucom_start_write = &uftdi_start_write,
 	.ucom_stop_write = &uftdi_stop_write,
+	.ucom_poll = &uftdi_poll,
 };
 
 static device_method_t uftdi_methods[] = {
@@ -808,3 +810,10 @@ done:
 	*rate = result;
 	return (0);
 }
+
+static void
+uftdi_poll(struct ucom_softc *ucom)
+{
+	struct uftdi_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UFTDI_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/ugensa.c
==============================================================================
--- stable/8/sys/dev/usb/serial/ugensa.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/ugensa.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -110,9 +110,9 @@ static void	ugensa_start_read(struct uco
 static void	ugensa_stop_read(struct ucom_softc *);
 static void	ugensa_start_write(struct ucom_softc *);
 static void	ugensa_stop_write(struct ucom_softc *);
+static void	ugensa_poll(struct ucom_softc *ucom);
 
-static const struct usb_config
-	ugensa_xfer_config[UGENSA_N_TRANSFER] = {
+static const struct usb_config ugensa_xfer_config[UGENSA_N_TRANSFER] = {
 
 	[UGENSA_BULK_DT_WR] = {
 		.type = UE_BULK,
@@ -138,6 +138,7 @@ static const struct ucom_callback ugensa
 	.ucom_stop_read = &ugensa_stop_read,
 	.ucom_start_write = &ugensa_start_write,
 	.ucom_stop_write = &ugensa_stop_write,
+	.ucom_poll = &ugensa_poll,
 };
 
 static device_method_t ugensa_methods[] = {
@@ -369,3 +370,12 @@ ugensa_stop_write(struct ucom_softc *uco
 
 	usbd_transfer_stop(ssc->sc_xfer[UGENSA_BULK_DT_WR]);
 }
+
+static void
+ugensa_poll(struct ucom_softc *ucom)
+{
+	struct ugensa_softc *sc = ucom->sc_parent;
+	struct ugensa_sub_softc *ssc = sc->sc_sub + ucom->sc_portno;
+
+	usbd_transfer_poll(ssc->sc_xfer, UGENSA_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/uipaq.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uipaq.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uipaq.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -122,6 +122,7 @@ static void	uipaq_stop_write(struct ucom
 static void	uipaq_cfg_set_dtr(struct ucom_softc *, uint8_t);
 static void	uipaq_cfg_set_rts(struct ucom_softc *, uint8_t);
 static void	uipaq_cfg_set_break(struct ucom_softc *, uint8_t);
+static void	uipaq_poll(struct ucom_softc *ucom);
 
 static const struct usb_config uipaq_config_data[UIPAQ_N_TRANSFER] = {
 
@@ -152,6 +153,7 @@ static const struct ucom_callback uipaq_
 	.ucom_stop_read = &uipaq_stop_read,
 	.ucom_start_write = &uipaq_start_write,
 	.ucom_stop_write = &uipaq_stop_write,
+	.ucom_poll = &uipaq_poll,
 };
 
 /*
@@ -1342,3 +1344,10 @@ tr_setup:
 		return;
 	}
 }
+
+static void
+uipaq_poll(struct ucom_softc *ucom)
+{
+	struct uipaq_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UIPAQ_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/umct.c
==============================================================================
--- stable/8/sys/dev/usb/serial/umct.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/umct.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -142,6 +142,7 @@ static void	umct_start_read(struct ucom_
 static void	umct_stop_read(struct ucom_softc *);
 static void	umct_start_write(struct ucom_softc *);
 static void	umct_stop_write(struct ucom_softc *);
+static void	umct_poll(struct ucom_softc *ucom);
 
 static const struct usb_config umct_config[UMCT_N_TRANSFER] = {
 
@@ -186,6 +187,7 @@ static const struct ucom_callback umct_c
 	.ucom_stop_read = &umct_stop_read,
 	.ucom_start_write = &umct_start_write,
 	.ucom_stop_write = &umct_stop_write,
+	.ucom_poll = &umct_poll,
 };
 
 static const struct usb_device_id umct_devs[] = {
@@ -603,3 +605,10 @@ tr_setup:
 		return;
 	}
 }
+
+static void
+umct_poll(struct ucom_softc *ucom)
+{
+	struct umct_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UMCT_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/umodem.c
==============================================================================
--- stable/8/sys/dev/usb/serial/umodem.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/umodem.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -196,6 +196,7 @@ static void	umodem_cfg_set_break(struct 
 static void	*umodem_get_desc(struct usb_attach_arg *, uint8_t, uint8_t);
 static usb_error_t umodem_set_comm_feature(struct usb_device *, uint8_t,
 		    uint16_t, uint16_t);
+static void	umodem_poll(struct ucom_softc *ucom);
 
 static const struct usb_config umodem_config[UMODEM_N_TRANSFER] = {
 
@@ -242,6 +243,7 @@ static const struct ucom_callback umodem
 	.ucom_stop_read = &umodem_stop_read,
 	.ucom_start_write = &umodem_start_write,
 	.ucom_stop_write = &umodem_stop_write,
+	.ucom_poll = &umodem_poll,
 };
 
 static device_method_t umodem_methods[] = {
@@ -810,3 +812,10 @@ umodem_detach(device_t dev)
 
 	return (0);
 }
+
+static void
+umodem_poll(struct ucom_softc *ucom)
+{
+	struct umodem_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UMODEM_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/umoscom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/umoscom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/umoscom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -210,6 +210,7 @@ static void	umoscom_start_read(struct uc
 static void	umoscom_stop_read(struct ucom_softc *);
 static void	umoscom_start_write(struct ucom_softc *);
 static void	umoscom_stop_write(struct ucom_softc *);
+static void	umoscom_poll(struct ucom_softc *ucom);
 
 static const struct usb_config umoscom_config_data[UMOSCOM_N_TRANSFER] = {
 
@@ -257,6 +258,7 @@ static const struct ucom_callback umosco
 	.ucom_stop_read = &umoscom_stop_read,
 	.ucom_start_write = &umoscom_start_write,
 	.ucom_stop_write = &umoscom_stop_write,
+	.ucom_poll = &umoscom_poll,
 };
 
 static device_method_t umoscom_methods[] = {
@@ -694,3 +696,10 @@ tr_setup:
 		return;
 	}
 }
+
+static void
+umoscom_poll(struct ucom_softc *ucom)
+{
+	struct umoscom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UMOSCOM_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/uplcom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uplcom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uplcom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -186,6 +186,7 @@ static void	uplcom_start_write(struct uc
 static void	uplcom_stop_write(struct ucom_softc *);
 static void	uplcom_cfg_get_status(struct ucom_softc *, uint8_t *,
 		    uint8_t *);
+static void	uplcom_poll(struct ucom_softc *ucom);
 
 static device_probe_t uplcom_probe;
 static device_attach_t uplcom_attach;
@@ -239,6 +240,7 @@ static struct ucom_callback uplcom_callb
 	.ucom_stop_read = &uplcom_stop_read,
 	.ucom_start_write = &uplcom_start_write,
 	.ucom_stop_write = &uplcom_stop_write,
+	.ucom_poll = &uplcom_poll,
 };
 
 #define	USB_UPL(v,p,rl,rh,t)				\
@@ -862,3 +864,10 @@ tr_setup:
 		return;
 	}
 }
+
+static void
+uplcom_poll(struct ucom_softc *ucom)
+{
+	struct uplcom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UPLCOM_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/usb_serial.c
==============================================================================
--- stable/8/sys/dev/usb/serial/usb_serial.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/usb_serial.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -86,6 +86,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -98,14 +100,40 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include "opt_gdb.h"
+
+SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom");
+
 #if USB_DEBUG
 static int ucom_debug = 0;
 
-SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom");
 SYSCTL_INT(_hw_usb_ucom, OID_AUTO, debug, CTLFLAG_RW,
     &ucom_debug, 0, "ucom debug level");
 #endif
 
+#define	UCOM_CONS_BUFSIZE 1024
+
+static uint8_t ucom_cons_rx_buf[UCOM_CONS_BUFSIZE];
+static uint8_t ucom_cons_tx_buf[UCOM_CONS_BUFSIZE];
+
+static unsigned int ucom_cons_rx_low = 0;
+static unsigned int ucom_cons_rx_high = 0;
+
+static unsigned int ucom_cons_tx_low = 0;
+static unsigned int ucom_cons_tx_high = 0;
+
+static int ucom_cons_unit = -1;
+static int ucom_cons_baud = 9600;
+static struct ucom_softc *ucom_cons_softc = NULL;
+
+TUNABLE_INT("hw.usb.ucom.cons_unit", &ucom_cons_unit);
+SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RW,
+    &ucom_cons_unit, 0, "console unit number");
+
+TUNABLE_INT("hw.usb.ucom.cons_baud", &ucom_cons_baud);
+SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RW,
+    &ucom_cons_baud, 0, "console baud rate");
+
 static usb_proc_callback_t ucom_cfg_start_transfers;
 static usb_proc_callback_t ucom_cfg_open;
 static usb_proc_callback_t ucom_cfg_close;
@@ -121,6 +149,7 @@ static void	ucom_queue_command(struct uc
 		    usb_proc_callback_t *, struct termios *pt,
 		    struct usb_proc_msg *t0, struct usb_proc_msg *t1);
 static void	ucom_shutdown(struct ucom_softc *);
+static void	ucom_ring(struct ucom_softc *, uint8_t);
 static void	ucom_break(struct ucom_softc *, uint8_t);
 static void	ucom_dtr(struct ucom_softc *, uint8_t);
 static void	ucom_rts(struct ucom_softc *, uint8_t);
@@ -147,7 +176,7 @@ static struct ttydevsw ucom_class = {
 MODULE_DEPEND(ucom, usb, 1, 1, 1);
 MODULE_VERSION(ucom, 1);
 
-#define	UCOM_UNIT_MAX 0x1000		/* exclusive */
+#define	UCOM_UNIT_MAX 0x200		/* exclusive */
 #define	UCOM_SUB_UNIT_MAX 0x100		/* exclusive */
 
 static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8];
@@ -346,6 +375,29 @@ ucom_attach_tty(struct ucom_softc *sc, u
 	DPRINTF("ttycreate: %s\n", buf);
 	cv_init(&sc->sc_cv, "ucom");
 
+	/* Check if this device should be a console */
+	if ((ucom_cons_softc == NULL) && 
+	    (sc->sc_unit == ucom_cons_unit)) {
+
+		struct termios t;
+
+		ucom_cons_softc = sc;
+
+		memset(&t, 0, sizeof(t));
+		t.c_ispeed = ucom_cons_baud;
+		t.c_ospeed = t.c_ispeed;
+		t.c_cflag = CS8;
+
+		mtx_lock(ucom_cons_softc->sc_mtx);
+		ucom_cons_rx_low = 0;
+		ucom_cons_rx_high = 0;
+		ucom_cons_tx_low = 0;
+		ucom_cons_tx_high = 0;
+		sc->sc_flag |= UCOM_FLAG_CONSOLE;
+		ucom_open(ucom_cons_softc->sc_tty);
+		ucom_param(ucom_cons_softc->sc_tty, &t);
+		mtx_unlock(ucom_cons_softc->sc_mtx);
+	}
 done:
 	return (error);
 }
@@ -357,12 +409,18 @@ ucom_detach_tty(struct ucom_softc *sc)
 
 	DPRINTF("sc = %p, tp = %p\n", sc, sc->sc_tty);
 
+	if (sc->sc_flag & UCOM_FLAG_CONSOLE) {
+		mtx_lock(ucom_cons_softc->sc_mtx);
+		ucom_close(ucom_cons_softc->sc_tty);
+		mtx_unlock(ucom_cons_softc->sc_mtx);
+		ucom_cons_softc = NULL;
+	}
+
 	/* the config thread has been stopped when we get here */
 
 	mtx_lock(sc->sc_mtx);
 	sc->sc_flag |= UCOM_FLAG_GONE;
-	sc->sc_flag &= ~(UCOM_FLAG_HL_READY |
-	    UCOM_FLAG_LL_READY);
+	sc->sc_flag &= ~(UCOM_FLAG_HL_READY | UCOM_FLAG_LL_READY);
 	mtx_unlock(sc->sc_mtx);
 	if (tp) {
 		tty_lock(tp);
@@ -588,6 +646,8 @@ ucom_open(struct tty *tp)
 
 	ucom_modem(tp, SER_DTR | SER_RTS, 0);
 
+	ucom_ring(sc, 0);
+
 	ucom_break(sc, 0);
 
 	ucom_status_change(sc);
@@ -653,6 +713,16 @@ ucom_ioctl(struct tty *tp, u_long cmd, c
 	DPRINTF("cmd = 0x%08lx\n", cmd);
 
 	switch (cmd) {
+#if 0
+	case TIOCSRING:
+		ucom_ring(sc, 1);
+		error = 0;
+		break;
+	case TIOCCRING:
+		ucom_ring(sc, 0);
+		error = 0;
+		break;
+#endif
 	case TIOCSBRK:
 		ucom_break(sc, 1);
 		error = 0;
@@ -751,6 +821,8 @@ ucom_cfg_line_state(struct usb_proc_msg 
 		mask |= UCOM_LS_RTS;
 	if (sc->sc_callback->ucom_cfg_set_break)
 		mask |= UCOM_LS_BREAK;
+	if (sc->sc_callback->ucom_cfg_set_ring)
+		mask |= UCOM_LS_RING;
 
 	/* compute the bits we are to program */
 	notch_bits = (sc->sc_pls_set & sc->sc_pls_clr) & mask;
@@ -773,6 +845,9 @@ ucom_cfg_line_state(struct usb_proc_msg 
 	if (notch_bits & UCOM_LS_BREAK)
 		sc->sc_callback->ucom_cfg_set_break(sc,
 		    (prev_value & UCOM_LS_BREAK) ? 1 : 0);
+	if (notch_bits & UCOM_LS_RING)
+		sc->sc_callback->ucom_cfg_set_ring(sc,
+		    (prev_value & UCOM_LS_RING) ? 1 : 0);
 
 	/* set last value */
 	if (any_bits & UCOM_LS_DTR)
@@ -784,6 +859,9 @@ ucom_cfg_line_state(struct usb_proc_msg 
 	if (any_bits & UCOM_LS_BREAK)
 		sc->sc_callback->ucom_cfg_set_break(sc,
 		    (last_value & UCOM_LS_BREAK) ? 1 : 0);
+	if (any_bits & UCOM_LS_RING)
+		sc->sc_callback->ucom_cfg_set_ring(sc,
+		    (last_value & UCOM_LS_RING) ? 1 : 0);
 }
 
 static void
@@ -811,6 +889,17 @@ ucom_line_state(struct ucom_softc *sc,
 }
 
 static void
+ucom_ring(struct ucom_softc *sc, uint8_t onoff)
+{
+	DPRINTF("onoff = %d\n", onoff);
+
+	if (onoff)
+		ucom_line_state(sc, UCOM_LS_RING, 0);
+	else
+		ucom_line_state(sc, 0, UCOM_LS_RING);
+}
+
+static void
 ucom_break(struct ucom_softc *sc, uint8_t onoff)
 {
 	DPRINTF("onoff = %d\n", onoff);
@@ -895,6 +984,9 @@ ucom_status_change(struct ucom_softc *sc
 {
 	mtx_assert(sc->sc_mtx, MA_OWNED);
 
+	if (sc->sc_flag & UCOM_FLAG_CONSOLE)
+		return;		/* not supported */
+
 	if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) {
 		return;
 	}
@@ -1033,6 +1125,38 @@ ucom_get_data(struct ucom_softc *sc, str
 
 	mtx_assert(sc->sc_mtx, MA_OWNED);
 
+	if (sc->sc_flag & UCOM_FLAG_CONSOLE) {
+		unsigned int temp;
+
+		/* get total TX length */
+
+		temp = ucom_cons_tx_high - ucom_cons_tx_low;
+		temp %= UCOM_CONS_BUFSIZE;
+
+		/* limit TX length */
+
+		if (temp > (UCOM_CONS_BUFSIZE - ucom_cons_tx_low))
+			temp = (UCOM_CONS_BUFSIZE - ucom_cons_tx_low);
+
+		if (temp > len)
+			temp = len;
+
+		/* copy in data */
+
+		usbd_copy_in(pc, offset, ucom_cons_tx_buf + ucom_cons_tx_low, temp);
+
+		/* update counters */
+
+		ucom_cons_tx_low += temp;
+		ucom_cons_tx_low %= UCOM_CONS_BUFSIZE;
+
+		/* store actual length */
+
+		*actlen = temp;
+
+		return (temp ? 1 : 0);
+	}
+
 	if (tty_gone(tp) ||
 	    !(sc->sc_flag & UCOM_FLAG_GP_DATA)) {
 		actlen[0] = 0;
@@ -1080,6 +1204,34 @@ ucom_put_data(struct ucom_softc *sc, str
 
 	mtx_assert(sc->sc_mtx, MA_OWNED);
 
+	if (sc->sc_flag & UCOM_FLAG_CONSOLE) {
+		unsigned int temp;
+
+		/* get maximum RX length */
+
+		temp = (UCOM_CONS_BUFSIZE - 1) - ucom_cons_rx_high + ucom_cons_rx_low;
+		temp %= UCOM_CONS_BUFSIZE;
+
+		/* limit RX length */
+
+		if (temp > (UCOM_CONS_BUFSIZE - ucom_cons_rx_high))
+			temp = (UCOM_CONS_BUFSIZE - ucom_cons_rx_high);
+
+		if (temp > len)
+			temp = len;
+
+		/* copy out data */
+
+		usbd_copy_out(pc, offset, ucom_cons_rx_buf + ucom_cons_rx_high, temp);
+
+		/* update counters */
+
+		ucom_cons_rx_high += temp;
+		ucom_cons_rx_high %= UCOM_CONS_BUFSIZE;
+
+		return;
+	}
+
 	if (tty_gone(tp))
 		return;			/* multiport device polling */
 
@@ -1136,3 +1288,138 @@ ucom_free(void *xsc)
 	cv_signal(&sc->sc_cv);
 	mtx_unlock(sc->sc_mtx);
 }
+
+static cn_probe_t ucom_cnprobe;
+static cn_init_t ucom_cninit;
+static cn_term_t ucom_cnterm;
+static cn_getc_t ucom_cngetc;
+static cn_putc_t ucom_cnputc;
+
+CONSOLE_DRIVER(ucom);
+
+static void
+ucom_cnprobe(struct consdev  *cp)
+{
+	cp->cn_pri = CN_NORMAL;
+}
+
+static void
+ucom_cninit(struct consdev  *cp)
+{
+}
+
+static void
+ucom_cnterm(struct consdev  *cp)
+{
+}
+
+static int
+ucom_cngetc(struct consdev *cd)
+{
+	struct ucom_softc *sc = ucom_cons_softc;
+	int c;
+
+	if (sc == NULL)
+		return (-1);
+
+	mtx_lock(sc->sc_mtx);
+
+	if (ucom_cons_rx_low != ucom_cons_rx_high) {
+		c = ucom_cons_rx_buf[ucom_cons_rx_low];
+		ucom_cons_rx_low ++;
+		ucom_cons_rx_low %= UCOM_CONS_BUFSIZE;
+	} else {
+		c = -1;
+	}
+
+	/* start USB transfers */
+	ucom_outwakeup(sc->sc_tty);
+
+	mtx_unlock(sc->sc_mtx);
+
+	/* poll if necessary */
+	if (kdb_active && sc->sc_callback->ucom_poll)
+		(sc->sc_callback->ucom_poll) (sc);
+
+	return (c);
+}
+
+static void
+ucom_cnputc(struct consdev *cd, int c)
+{
+	struct ucom_softc *sc = ucom_cons_softc;
+	unsigned int temp;
+
+	if (sc == NULL)
+		return;
+
+ repeat:
+
+	mtx_lock(sc->sc_mtx);
+
+	/* compute maximum TX length */
+
+	temp = (UCOM_CONS_BUFSIZE - 1) - ucom_cons_tx_high + ucom_cons_tx_low;
+	temp %= UCOM_CONS_BUFSIZE;
+
+	if (temp) {
+		ucom_cons_tx_buf[ucom_cons_tx_high] = c;
+		ucom_cons_tx_high ++;
+		ucom_cons_tx_high %= UCOM_CONS_BUFSIZE;
+	}
+
+	/* start USB transfers */
+	ucom_outwakeup(sc->sc_tty);
+
+	mtx_unlock(sc->sc_mtx);
+
+	/* poll if necessary */
+	if (kdb_active && sc->sc_callback->ucom_poll) {
+		(sc->sc_callback->ucom_poll) (sc);
+		/* simple flow control */
+		if (temp == 0)
+			goto repeat;
+	}
+}
+
+#if defined(GDB)
+
+#include 
+
+static gdb_probe_f ucom_gdbprobe;
+static gdb_init_f ucom_gdbinit;
+static gdb_term_f ucom_gdbterm;
+static gdb_getc_f ucom_gdbgetc;
+static gdb_putc_f ucom_gdbputc;
+
+GDB_DBGPORT(sio, ucom_gdbprobe, ucom_gdbinit, ucom_gdbterm, ucom_gdbgetc, ucom_gdbputc);
+
+static int
+ucom_gdbprobe(void)
+{
+	return ((ucom_cons_softc != NULL) ? 0 : -1);
+}
+
+static void
+ucom_gdbinit(void)
+{
+}
+
+static void
+ucom_gdbterm(void)
+{
+}
+
+static void
+ucom_gdbputc(int c)
+{
+        ucom_cnputc(NULL, c);
+}
+
+static int
+ucom_gdbgetc(void)
+{
+        return (ucom_cngetc(NULL));
+}
+
+#endif

Modified: stable/8/sys/dev/usb/serial/usb_serial.h
==============================================================================
--- stable/8/sys/dev/usb/serial/usb_serial.h	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/usb_serial.h	Thu Oct 29 23:23:34 2009	(r198655)
@@ -94,6 +94,7 @@ struct ucom_callback {
 	void    (*ucom_cfg_set_dtr) (struct ucom_softc *, uint8_t);
 	void    (*ucom_cfg_set_rts) (struct ucom_softc *, uint8_t);
 	void    (*ucom_cfg_set_break) (struct ucom_softc *, uint8_t);
+	void    (*ucom_cfg_set_ring) (struct ucom_softc *, uint8_t);
 	void    (*ucom_cfg_param) (struct ucom_softc *, struct termios *);
 	void    (*ucom_cfg_open) (struct ucom_softc *);
 	void    (*ucom_cfg_close) (struct ucom_softc *);
@@ -105,6 +106,7 @@ struct ucom_callback {
 	void    (*ucom_start_write) (struct ucom_softc *);
 	void    (*ucom_stop_write) (struct ucom_softc *);
 	void    (*ucom_tty_name) (struct ucom_softc *, char *pbuf, uint16_t buflen, uint16_t local_subunit);
+	void    (*ucom_poll) (struct ucom_softc *);
 };
 
 /* Line status register */
@@ -162,13 +164,14 @@ struct ucom_softc {
 	uint32_t sc_unit;
 	uint32_t sc_local_unit;
 	uint16_t sc_portno;
-	uint8_t	sc_flag;
+	uint16_t sc_flag;
 #define	UCOM_FLAG_RTS_IFLOW	0x01	/* use RTS input flow control */
 #define	UCOM_FLAG_GONE		0x02	/* the device is gone */
 #define	UCOM_FLAG_ATTACHED	0x04	/* set if attached */
 #define	UCOM_FLAG_GP_DATA	0x08	/* set if get and put data is possible */
 #define	UCOM_FLAG_LL_READY	0x20	/* set if low layer is ready */
 #define	UCOM_FLAG_HL_READY	0x40	/* set if high layer is ready */
+#define	UCOM_FLAG_CONSOLE	0x80	/* set if device is a console */
 	uint8_t	sc_lsr;
 	uint8_t	sc_msr;
 	uint8_t	sc_mcr;
@@ -180,6 +183,7 @@ struct ucom_softc {
 #define	UCOM_LS_DTR	0x01
 #define	UCOM_LS_RTS	0x02
 #define	UCOM_LS_BREAK	0x04
+#define	UCOM_LS_RING	0x08
 };
 
 #define	ucom_cfg_do_request(udev,com,req,ptr,flags,timo) \

Modified: stable/8/sys/dev/usb/serial/uslcom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uslcom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uslcom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -135,6 +135,7 @@ static void uslcom_start_read(struct uco
 static void uslcom_stop_read(struct ucom_softc *);
 static void uslcom_start_write(struct ucom_softc *);
 static void uslcom_stop_write(struct ucom_softc *);
+static void uslcom_poll(struct ucom_softc *ucom);
 
 static const struct usb_config uslcom_config[USLCOM_N_TRANSFER] = {
 
@@ -170,6 +171,7 @@ static struct ucom_callback uslcom_callb
 	.ucom_stop_read = &uslcom_stop_read,
 	.ucom_start_write = &uslcom_start_write,
 	.ucom_stop_write = &uslcom_stop_write,
+	.ucom_poll = &uslcom_poll,
 };
 
 static const struct usb_device_id uslcom_devs[] = {
@@ -562,3 +564,10 @@ uslcom_stop_write(struct ucom_softc *uco
 
 	usbd_transfer_stop(sc->sc_xfer[USLCOM_BULK_DT_WR]);
 }
+
+static void
+uslcom_poll(struct ucom_softc *ucom)
+{
+	struct uslcom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, USLCOM_N_TRANSFER);
+}

Modified: stable/8/sys/dev/usb/serial/uvscom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uvscom.c	Thu Oct 29 23:22:54 2009	(r198654)
+++ stable/8/sys/dev/usb/serial/uvscom.c	Thu Oct 29 23:23:34 2009	(r198655)
@@ -185,6 +185,7 @@ static void	uvscom_cfg_get_status(struct
 		    uint8_t *);
 static void	uvscom_cfg_write(struct uvscom_softc *, uint8_t, uint16_t);
 static uint16_t	uvscom_cfg_read_status(struct uvscom_softc *);
+static void	uvscom_poll(struct ucom_softc *ucom);
 
 static const struct usb_config uvscom_config[UVSCOM_N_TRANSFER] = {
 
@@ -230,6 +231,7 @@ static const struct ucom_callback uvscom
 	.ucom_stop_read = &uvscom_stop_read,
 	.ucom_start_write = &uvscom_start_write,
 	.ucom_stop_write = &uvscom_stop_write,
+	.ucom_poll = &uvscom_poll,
 };
 
 static const struct usb_device_id uvscom_devs[] = {
@@ -734,3 +736,10 @@ uvscom_cfg_read_status(struct uvscom_sof
 	}
 	return (data[0] | (data[1] << 8));
 }
+
+static void
+uvscom_poll(struct ucom_softc *ucom)
+{
+	struct uvscom_softc *sc = ucom->sc_parent;
+	usbd_transfer_poll(sc->sc_xfer, UVSCOM_N_TRANSFER);
+}

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:24:10 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B949C1065696;
	Thu, 29 Oct 2009 23:24:10 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A4B788FC1D;
	Thu, 29 Oct 2009 23:24:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNOAWD015400;
	Thu, 29 Oct 2009 23:24:10 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNOABg015398;
	Thu, 29 Oct 2009 23:24:10 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292324.n9TNOABg015398@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:24:10 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198656 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:24:10 -0000

Author: thompsa
Date: Thu Oct 29 23:24:10 2009
New Revision: 198656
URL: http://svn.freebsd.org/changeset/base/198656

Log:
  MFC r197572
  
   Add new FTDI IDs.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/uftdi.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/uftdi.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uftdi.c	Thu Oct 29 23:23:34 2009	(r198655)
+++ stable/8/sys/dev/usb/serial/uftdi.c	Thu Oct 29 23:24:10 2009	(r198656)
@@ -243,10 +243,13 @@ static struct usb_device_id uftdi_devs[]
 	{USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_PCMSFU, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_EMCU2H, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_MAXSTREAM, UFTDI_TYPE_8U232AM)},
+	{USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_CTI_USB_NANO_485, UFTDI_TYPE_8U232AM)},
+	{USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_CTI_USB_MINI_485, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_SIIG2, USB_PRODUCT_SIIG2_US2308, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_INTREPIDCS, USB_PRODUCT_INTREPIDCS_VALUECAN, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_INTREPIDCS, USB_PRODUCT_INTREPIDCS_NEOVI, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_BBELECTRONICS, USB_PRODUCT_BBELECTRONICS_USOTL4, UFTDI_TYPE_8U232AM)},
+	{USB_VPI(USB_VENDOR_MARVELL, USB_PRODUCT_MARVELL_SHEEVAPLUG, UFTDI_TYPE_8U232AM)},
 	{USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_PCOPRS1, UFTDI_TYPE_8U232AM)},
 };
 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:24:41 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C567810656A3;
	Thu, 29 Oct 2009 23:24:41 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B0C918FC27;
	Thu, 29 Oct 2009 23:24:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNOfGk015488;
	Thu, 29 Oct 2009 23:24:41 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNOfKo015486;
	Thu, 29 Oct 2009 23:24:41 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292324.n9TNOfKo015486@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:24:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198657 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:24:42 -0000

Author: thompsa
Date: Thu Oct 29 23:24:41 2009
New Revision: 198657
URL: http://svn.freebsd.org/changeset/base/198657

Log:
  MFC r197573
  
   Add back endpoint swap detection that was disabled in an earlier driver
   conversion.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/umct.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/umct.c
==============================================================================
--- stable/8/sys/dev/usb/serial/umct.c	Thu Oct 29 23:24:10 2009	(r198656)
+++ stable/8/sys/dev/usb/serial/umct.c	Thu Oct 29 23:24:41 2009	(r198657)
@@ -115,6 +115,7 @@ struct umct_softc {
 	uint8_t	sc_lcr;
 	uint8_t	sc_mcr;
 	uint8_t	sc_iface_no;
+	uint8_t sc_swap_cb;
 	uint8_t	sc_name[16];
 };
 
@@ -125,8 +126,10 @@ static device_attach_t umct_attach;
 static device_detach_t umct_detach;
 
 static usb_callback_t umct_intr_callback;
-static usb_callback_t umct_write_callback;
+static usb_callback_t umct_intr_callback_sub;
 static usb_callback_t umct_read_callback;
+static usb_callback_t umct_read_callback_sub;
+static usb_callback_t umct_write_callback;
 
 static void	umct_cfg_do_request(struct umct_softc *sc, uint8_t request,
 		    uint16_t len, uint32_t value);
@@ -240,7 +243,7 @@ umct_attach(device_t dev)
 	struct usb_attach_arg *uaa = device_get_ivars(dev);
 	struct umct_softc *sc = device_get_softc(dev);
 	int32_t error;
-	//uint16_t maxp;
+	uint16_t maxp;
 	uint8_t iface_index;
 
 	sc->sc_udev = uaa->device;
@@ -263,13 +266,13 @@ umct_attach(device_t dev)
 		    "transfers failed!\n");
 		goto detach;
 	}
+
 	/*
 	 * The real bulk-in endpoint is also marked as an interrupt.
 	 * The only way to differentiate it from the real interrupt
 	 * endpoint is to look at the wMaxPacketSize field.
 	 */
-#ifdef XXX
-	maxp = UGETW(sc->sc_xfer[UMCT_BULK_DT_RD]->endpoint->edesc->wMaxPacketSize);
+	maxp = usbd_xfer_max_framelen(sc->sc_xfer[UMCT_BULK_DT_RD]);
 	if (maxp == 0x2) {
 
 		/* guessed wrong - switch around endpoints */
@@ -278,11 +281,9 @@ umct_attach(device_t dev)
 
 		sc->sc_xfer[UMCT_INTR_DT_RD] = sc->sc_xfer[UMCT_BULK_DT_RD];
 		sc->sc_xfer[UMCT_BULK_DT_RD] = temp;
-
-		sc->sc_xfer[UMCT_BULK_DT_RD]->callback = &umct_read_callback;
-		sc->sc_xfer[UMCT_INTR_DT_RD]->callback = &umct_intr_callback;
+		sc->sc_swap_cb = 1;
 	}
-#endif
+
 	sc->sc_obufsize = usbd_xfer_max_len(sc->sc_xfer[UMCT_BULK_DT_WR]);
 
 	if (uaa->info.idProduct == USB_PRODUCT_MCT_SITECOM_USB232) {
@@ -342,7 +343,7 @@ umct_cfg_do_request(struct umct_softc *s
 }
 
 static void
-umct_intr_callback(struct usb_xfer *xfer, usb_error_t error)
+umct_intr_callback_sub(struct usb_xfer *xfer, usb_error_t error)
 {
 	struct umct_softc *sc = usbd_xfer_softc(xfer);
 	struct usb_page_cache *pc;
@@ -547,6 +548,28 @@ umct_stop_write(struct ucom_softc *ucom)
 }
 
 static void
+umct_read_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct umct_softc *sc = usbd_xfer_softc(xfer);
+
+	if (sc->sc_swap_cb)
+		umct_intr_callback_sub(xfer, error);
+	else
+		umct_read_callback_sub(xfer, error);
+}
+
+static void
+umct_intr_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct umct_softc *sc = usbd_xfer_softc(xfer);
+
+	if (sc->sc_swap_cb)
+		umct_read_callback_sub(xfer, error);
+	else
+		umct_intr_callback_sub(xfer, error);
+}
+
+static void
 umct_write_callback(struct usb_xfer *xfer, usb_error_t error)
 {
 	struct umct_softc *sc = usbd_xfer_softc(xfer);
@@ -577,7 +600,7 @@ tr_setup:
 }
 
 static void
-umct_read_callback(struct usb_xfer *xfer, usb_error_t error)
+umct_read_callback_sub(struct usb_xfer *xfer, usb_error_t error)
 {
 	struct umct_softc *sc = usbd_xfer_softc(xfer);
 	struct usb_page_cache *pc;

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:25:14 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 38031106568D;
	Thu, 29 Oct 2009 23:25:14 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 237138FC0A;
	Thu, 29 Oct 2009 23:25:14 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNPEBR015585;
	Thu, 29 Oct 2009 23:25:14 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNPEFH015583;
	Thu, 29 Oct 2009 23:25:14 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292325.n9TNPEFH015583@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:25:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198658 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/input dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:25:14 -0000

Author: thompsa
Date: Thu Oct 29 23:25:13 2009
New Revision: 198658
URL: http://svn.freebsd.org/changeset/base/198658

Log:
  MFC r197999 (hrs)
  
   Fix the 106/109 USB Japanese keyboard "underscore" issue.
   Sun Type 6 USB keyboard support added in rev 1.46 conflicted with
   some scan codes used in Japanese keyboards because the scan code
   conversion routine was ambiguous for the overlapped codes.
  
  PR:		ports/134005

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/input/ukbd.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/input/ukbd.c
==============================================================================
--- stable/8/sys/dev/usb/input/ukbd.c	Thu Oct 29 23:24:41 2009	(r198657)
+++ stable/8/sys/dev/usb/input/ukbd.c	Thu Oct 29 23:25:13 2009	(r198658)
@@ -247,8 +247,8 @@ static const uint8_t ukbd_trtab[256] = {
 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 68 - 6F */
 	NN, NN, NN, NN, 115, 108, 111, 113,	/* 70 - 77 */
 	109, 110, 112, 118, 114, 116, 117, 119,	/* 78 - 7F */
-	121, 120, NN, NN, NN, NN, NN, 115,	/* 80 - 87 */
-	112, 125, 121, 123, NN, NN, NN, NN,	/* 88 - 8F */
+	121, 120, NN, NN, NN, NN, NN, 123,	/* 80 - 87 */
+	124, 125, 126, 127, 128, NN, NN, NN,	/* 88 - 8F */
 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 90 - 97 */
 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 98 - 9F */
 	NN, NN, NN, NN, NN, NN, NN, NN,	/* A0 - A7 */
@@ -1636,20 +1636,59 @@ static int
 ukbd_key2scan(struct ukbd_softc *sc, int code, int shift, int up)
 {
 	static const int scan[] = {
-		0x1c, 0x1d, 0x35,
-		0x37 | SCAN_PREFIX_SHIFT,	/* PrintScreen */
-		0x38, 0x47, 0x48, 0x49, 0x4b, 0x4d, 0x4f,
-		0x50, 0x51, 0x52, 0x53,
-		0x46,			/* XXX Pause/Break */
-		0x5b, 0x5c, 0x5d,
+		/* 89 */
+		0x11c,	/* Enter */
+		/* 90-99 */
+		0x11d,	/* Ctrl-R */
+		0x135,	/* Divide */
+		0x137 | SCAN_PREFIX_SHIFT,	/* PrintScreen */
+		0x138,	/* Alt-R */
+		0x147,	/* Home */
+		0x148,	/* Up */
+		0x149,	/* PageUp */
+		0x14b,	/* Left */
+		0x14d,	/* Right */
+		0x14f,	/* End */
+		/* 100-109 */
+		0x150,	/* Down */
+		0x151,	/* PageDown */
+		0x152,	/* Insert */
+		0x153,	/* Delete */
+		0x146,	/* XXX Pause/Break */
+		0x15b,	/* Win_L(Super_L) */
+		0x15c,	/* Win_R(Super_R) */
+		0x15d,	/* Application(Menu) */
+
 		/* SUN TYPE 6 USB KEYBOARD */
-		0x68, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
-		0x64, 0x65, 0x66, 0x67, 0x25, 0x1f, 0x1e,
-		0x20,
+		0x168,	/* Sun Type 6 Help */
+		0x15e,	/* Sun Type 6 Stop */
+		/* 110 - 119 */
+		0x15f,	/* Sun Type 6 Again */
+		0x160,	/* Sun Type 6 Props */
+		0x161,	/* Sun Type 6 Undo */
+		0x162,	/* Sun Type 6 Front */
+		0x163,	/* Sun Type 6 Copy */
+		0x164,	/* Sun Type 6 Open */
+		0x165,	/* Sun Type 6 Paste */
+		0x166,	/* Sun Type 6 Find */
+		0x167,	/* Sun Type 6 Cut */
+		0x125,	/* Sun Type 6 Mute */
+		/* 120 - 128 */
+		0x11f,	/* Sun Type 6 VolumeDown */
+		0x11e,	/* Sun Type 6 VolumeUp */
+		0x120,	/* Sun Type 6 PowerDown */
+
+		/* Japanese 106/109 keyboard */
+		0x73,	/* Keyboard Intl' 1 (backslash / underscore) */
+		0x70,	/* Keyboard Intl' 2 (Katakana / Hiragana) */
+		0x7d,	/* Keyboard Intl' 3 (Yen sign) (Not using in jp106/109) */
+		0x79,	/* Keyboard Intl' 4 (Henkan) */
+		0x7b,	/* Keyboard Intl' 5 (Muhenkan) */
+		0x5c,	/* Keyboard Intl' 6 (Keypad ,) (For PC-9821 layout) */
 	};
 
 	if ((code >= 89) && (code < (89 + (sizeof(scan) / sizeof(scan[0]))))) {
-		code = scan[code - 89] | SCAN_PREFIX_E0;
+		code = scan[code - 89];
 	}
 	/* Pause/Break */
 	if ((code == 104) && (!(shift & (MOD_CONTROL_L | MOD_CONTROL_R)))) {

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:25:53 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5C711106568B;
	Thu, 29 Oct 2009 23:25:53 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 468038FC1D;
	Thu, 29 Oct 2009 23:25:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNPrTm015695;
	Thu, 29 Oct 2009 23:25:53 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNPrGq015678;
	Thu, 29 Oct 2009 23:25:53 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292325.n9TNPrGq015678@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:25:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198659 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/pci dev/usb/controller dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:25:53 -0000

Author: thompsa
Date: Thu Oct 29 23:25:52 2009
New Revision: 198659
URL: http://svn.freebsd.org/changeset/base/198659

Log:
  MFC r198151
  
   Workaround buggy BIOS code in USB regard. By doing the BIOS to OS handover for
   all host controllers at the same time, we avoid problems where the BIOS will
   actually write to the USB registers of all the USB host controllers every time
   we handover one of them, and consequently reset the OS programmed values.

Added:
  stable/8/sys/dev/usb/controller/ehcireg.h
     - copied unchanged from r198151, head/sys/dev/usb/controller/ehcireg.h
  stable/8/sys/dev/usb/controller/ohcireg.h
     - copied unchanged from r198151, head/sys/dev/usb/controller/ohcireg.h
  stable/8/sys/dev/usb/controller/uhcireg.h
     - copied unchanged from r198151, head/sys/dev/usb/controller/uhcireg.h
Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/usb/controller/ehci.c
  stable/8/sys/dev/usb/controller/ehci.h
  stable/8/sys/dev/usb/controller/ehci_ixp4xx.c
  stable/8/sys/dev/usb/controller/ehci_mbus.c
  stable/8/sys/dev/usb/controller/ehci_pci.c
  stable/8/sys/dev/usb/controller/ohci.c
  stable/8/sys/dev/usb/controller/ohci.h
  stable/8/sys/dev/usb/controller/ohci_atmelarm.c
  stable/8/sys/dev/usb/controller/ohci_pci.c
  stable/8/sys/dev/usb/controller/uhci.c
  stable/8/sys/dev/usb/controller/uhci.h
  stable/8/sys/dev/usb/controller/uhci_pci.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/pci/pci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -62,6 +62,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include "pcib_if.h"
 #include "pci_if.h"
 
@@ -270,6 +274,13 @@ TUNABLE_INT("hw.pci.honor_msi_blacklist"
 SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD,
     &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI");
 
+static int pci_usb_takeover = 1;
+TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover);
+SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RD | CTLFLAG_TUN,
+    &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\
+Disable this if you depend on BIOS emulation of USB devices, that is\n\
+you use USB devices (like keyboard or mouse) but do not load USB drivers");
+
 /* Find a device_t by bus/slot/function in domain 0 */
 
 device_t
@@ -2569,6 +2580,106 @@ pci_assign_interrupt(device_t bus, devic
 	resource_list_add(&dinfo->resources, SYS_RES_IRQ, 0, irq, irq, 1);
 }
 
+/* Perform early OHCI takeover from SMM. */
+static void
+ohci_early_takeover(device_t self)
+{
+	struct resource *res;
+	uint32_t ctl;
+	int rid;
+	int i;
+
+	rid = PCIR_BAR(0);
+	res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+	if (res == NULL)
+		return;
+
+	ctl = bus_read_4(res, OHCI_CONTROL);
+	if (ctl & OHCI_IR) {
+		if (bootverbose)
+			printf("ohci early: "
+			    "SMM active, request owner change\n");
+		bus_write_4(res, OHCI_COMMAND_STATUS, OHCI_OCR);
+		for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) {
+			DELAY(1000);
+			ctl = bus_read_4(res, OHCI_CONTROL);
+		}
+		if (ctl & OHCI_IR) {
+			if (bootverbose)
+				printf("ohci early: "
+				    "SMM does not respond, resetting\n");
+			bus_write_4(res, OHCI_CONTROL, OHCI_HCFS_RESET);
+		}
+	}
+
+	bus_release_resource(self, SYS_RES_MEMORY, rid, res);
+}
+
+/* Perform early UHCI takeover from SMM. */
+static void
+uhci_early_takeover(device_t self)
+{
+	/*
+	 * Set the PIRQD enable bit and switch off all the others. We don't
+	 * want legacy support to interfere with us XXX Does this also mean
+	 * that the BIOS won't touch the keyboard anymore if it is connected
+	 * to the ports of the root hub?
+	 */
+	pci_write_config(self, PCI_LEGSUP, PCI_LEGSUP_USBPIRQDEN, 2);
+}
+
+/* Perform early EHCI takeover from SMM. */
+static void
+ehci_early_takeover(device_t self)
+{
+	struct resource *res;
+	uint32_t cparams;
+	uint32_t eec;
+	uint8_t eecp;
+	uint8_t bios_sem;
+	int rid;
+	int i;
+
+	rid = PCIR_BAR(0);
+	res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+	if (res == NULL)
+		return;
+
+	cparams = bus_read_4(res, EHCI_HCCPARAMS);
+
+	/* Synchronise with the BIOS if it owns the controller. */
+	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
+	    eecp = EHCI_EECP_NEXT(eec)) {
+		eec = pci_read_config(self, eecp, 4);
+		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) {
+			continue;
+		}
+		bios_sem = pci_read_config(self, eecp +
+		    EHCI_LEGSUP_BIOS_SEM, 1);
+		if (bios_sem == 0) {
+			continue;
+		}
+		if (bootverbose)
+			printf("ehci early: "
+			    "SMM active, request owner change\n");
+
+		pci_write_config(self, eecp + EHCI_LEGSUP_OS_SEM, 1, 1);
+
+		for (i = 0; (i < 100) && (bios_sem != 0); i++) {
+			DELAY(1000);
+			bios_sem = pci_read_config(self, eecp +
+			    EHCI_LEGSUP_BIOS_SEM, 1);
+		}
+
+		if (bios_sem != 0) {
+			if (bootverbose)
+				printf("ehci early: "
+				    "SMM does not respond\n");
+		}
+	}
+	bus_release_resource(self, SYS_RES_MEMORY, rid, res);
+}
+
 void
 pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask)
 {
@@ -2612,6 +2723,16 @@ pci_add_resources(device_t bus, device_t
 		pci_assign_interrupt(bus, dev, 0);
 #endif
 	}
+
+	if (pci_usb_takeover && pci_get_class(dev) == PCIC_SERIALBUS &&
+	    pci_get_subclass(dev) == PCIS_SERIALBUS_USB) {
+		if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_EHCI)
+			ehci_early_takeover(dev);
+		else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_OHCI)
+			ohci_early_takeover(dev);
+		else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_UHCI)
+			uhci_early_takeover(dev);
+	}
 }
 
 void

Modified: stable/8/sys/dev/usb/controller/ehci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ehci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	EHCI_BUS2SC(bus) \
    ((ehci_softc_t *)(((uint8_t *)(bus)) - \

Modified: stable/8/sys/dev/usb/controller/ehci.h
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci.h	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ehci.h	Thu Oct 29 23:25:52 2009	(r198659)
@@ -40,139 +40,6 @@
 
 #define	EHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128)
 
-/* PCI config registers  */
-#define	PCI_CBMEM		0x10	/* configuration base MEM */
-#define	PCI_INTERFACE_EHCI	0x20
-#define	PCI_USBREV		0x60	/* RO USB protocol revision */
-#define	PCI_USB_REV_MASK	0xff
-#define	PCI_USB_REV_PRE_1_0	0x00
-#define	PCI_USB_REV_1_0		0x10
-#define	PCI_USB_REV_1_1		0x11
-#define	PCI_USB_REV_2_0		0x20
-#define	PCI_EHCI_FLADJ		0x61	/* RW Frame len adj, SOF=59488+6*fladj */
-#define	PCI_EHCI_PORTWAKECAP	0x62	/* RW Port wake caps (opt)  */
-
-/* EHCI Extended Capabilities */
-#define	EHCI_EC_LEGSUP		0x01
-#define	EHCI_EECP_NEXT(x)	(((x) >> 8) & 0xff)
-#define	EHCI_EECP_ID(x)		((x) & 0xff)
-
-/* Legacy support extended capability */
-#define	EHCI_LEGSUP_BIOS_SEM		0x02
-#define	EHCI_LEGSUP_OS_SEM		0x03
-#define	EHCI_LEGSUP_USBLEGCTLSTS	0x04
-
-/* EHCI capability registers */
-#define	EHCI_CAPLENGTH		0x00	/* RO Capability register length field */
-/* reserved			0x01 */
-#define	EHCI_HCIVERSION		0x02	/* RO Interface version number */
-#define	EHCI_HCSPARAMS		0x04	/* RO Structural parameters */
-#define	EHCI_HCS_DEBUGPORT(x)	(((x) >> 20) & 0xf)
-#define	EHCI_HCS_P_INDICATOR(x) ((x) & 0x10000)
-#define	EHCI_HCS_N_CC(x)	(((x) >> 12) & 0xf)	/* # of companion ctlrs */
-#define	EHCI_HCS_N_PCC(x)	(((x) >> 8) & 0xf)	/* # of ports per comp. */
-#define	EHCI_HCS_PPC(x)		((x) & 0x10)	/* port power control */
-#define	EHCI_HCS_N_PORTS(x)	((x) & 0xf)	/* # of ports */
-#define	EHCI_HCCPARAMS		0x08	/* RO Capability parameters */
-#define	EHCI_HCC_EECP(x)	(((x) >> 8) & 0xff)	/* extended ports caps */
-#define	EHCI_HCC_IST(x)		(((x) >> 4) & 0xf)	/* isoc sched threshold */
-#define	EHCI_HCC_ASPC(x)	((x) & 0x4)	/* async sched park cap */
-#define	EHCI_HCC_PFLF(x)	((x) & 0x2)	/* prog frame list flag */
-#define	EHCI_HCC_64BIT(x)	((x) & 0x1)	/* 64 bit address cap */
-#define	EHCI_HCSP_PORTROUTE	0x0c	/* RO Companion port route description */
-
-/* EHCI operational registers.  Offset given by EHCI_CAPLENGTH register */
-#define	EHCI_USBCMD		0x00	/* RO, RW, WO Command register */
-#define	EHCI_CMD_ITC_M		0x00ff0000	/* RW interrupt threshold ctrl */
-#define	EHCI_CMD_ITC_1		0x00010000
-#define	EHCI_CMD_ITC_2		0x00020000
-#define	EHCI_CMD_ITC_4		0x00040000
-#define	EHCI_CMD_ITC_8		0x00080000
-#define	EHCI_CMD_ITC_16		0x00100000
-#define	EHCI_CMD_ITC_32		0x00200000
-#define	EHCI_CMD_ITC_64		0x00400000
-#define	EHCI_CMD_ASPME		0x00000800	/* RW/RO async park enable */
-#define	EHCI_CMD_ASPMC		0x00000300	/* RW/RO async park count */
-#define	EHCI_CMD_LHCR		0x00000080	/* RW light host ctrl reset */
-#define	EHCI_CMD_IAAD		0x00000040	/* RW intr on async adv door
-						 * bell */
-#define	EHCI_CMD_ASE		0x00000020	/* RW async sched enable */
-#define	EHCI_CMD_PSE		0x00000010	/* RW periodic sched enable */
-#define	EHCI_CMD_FLS_M		0x0000000c	/* RW/RO frame list size */
-#define	EHCI_CMD_FLS(x)		(((x) >> 2) & 3)	/* RW/RO frame list size */
-#define	EHCI_CMD_HCRESET	0x00000002	/* RW reset */
-#define	EHCI_CMD_RS		0x00000001	/* RW run/stop */
-#define	EHCI_USBSTS		0x04	/* RO, RW, RWC Status register */
-#define	EHCI_STS_ASS		0x00008000	/* RO async sched status */
-#define	EHCI_STS_PSS		0x00004000	/* RO periodic sched status */
-#define	EHCI_STS_REC		0x00002000	/* RO reclamation */
-#define	EHCI_STS_HCH		0x00001000	/* RO host controller halted */
-#define	EHCI_STS_IAA		0x00000020	/* RWC interrupt on async adv */
-#define	EHCI_STS_HSE		0x00000010	/* RWC host system error */
-#define	EHCI_STS_FLR		0x00000008	/* RWC frame list rollover */
-#define	EHCI_STS_PCD		0x00000004	/* RWC port change detect */
-#define	EHCI_STS_ERRINT		0x00000002	/* RWC error interrupt */
-#define	EHCI_STS_INT		0x00000001	/* RWC interrupt */
-#define	EHCI_STS_INTRS(x)	((x) & 0x3f)
-
-/*
- * NOTE: the doorbell interrupt is enabled, but the doorbell is never
- * used! SiS chipsets require this.
- */
-#define	EHCI_NORMAL_INTRS	(EHCI_STS_IAA | EHCI_STS_HSE |	\
-				EHCI_STS_PCD | EHCI_STS_ERRINT | EHCI_STS_INT)
-
-#define	EHCI_USBINTR		0x08	/* RW Interrupt register */
-#define	EHCI_INTR_IAAE		0x00000020	/* interrupt on async advance
-						 * ena */
-#define	EHCI_INTR_HSEE		0x00000010	/* host system error ena */
-#define	EHCI_INTR_FLRE		0x00000008	/* frame list rollover ena */
-#define	EHCI_INTR_PCIE		0x00000004	/* port change ena */
-#define	EHCI_INTR_UEIE		0x00000002	/* USB error intr ena */
-#define	EHCI_INTR_UIE		0x00000001	/* USB intr ena */
-
-#define	EHCI_FRINDEX		0x0c	/* RW Frame Index register */
-
-#define	EHCI_CTRLDSSEGMENT	0x10	/* RW Control Data Structure Segment */
-
-#define	EHCI_PERIODICLISTBASE	0x14	/* RW Periodic List Base */
-#define	EHCI_ASYNCLISTADDR	0x18	/* RW Async List Base */
-
-#define	EHCI_CONFIGFLAG		0x40	/* RW Configure Flag register */
-#define	EHCI_CONF_CF		0x00000001	/* RW configure flag */
-
-#define	EHCI_PORTSC(n)		(0x40+(4*(n)))	/* RO, RW, RWC Port Status reg */
-#define	EHCI_PS_WKOC_E		0x00400000	/* RW wake on over current ena */
-#define	EHCI_PS_WKDSCNNT_E	0x00200000	/* RW wake on disconnect ena */
-#define	EHCI_PS_WKCNNT_E	0x00100000	/* RW wake on connect ena */
-#define	EHCI_PS_PTC		0x000f0000	/* RW port test control */
-#define	EHCI_PS_PIC		0x0000c000	/* RW port indicator control */
-#define	EHCI_PS_PO		0x00002000	/* RW port owner */
-#define	EHCI_PS_PP		0x00001000	/* RW,RO port power */
-#define	EHCI_PS_LS		0x00000c00	/* RO line status */
-#define	EHCI_PS_IS_LOWSPEED(x)	(((x) & EHCI_PS_LS) == 0x00000400)
-#define	EHCI_PS_PR		0x00000100	/* RW port reset */
-#define	EHCI_PS_SUSP		0x00000080	/* RW suspend */
-#define	EHCI_PS_FPR		0x00000040	/* RW force port resume */
-#define	EHCI_PS_OCC		0x00000020	/* RWC over current change */
-#define	EHCI_PS_OCA		0x00000010	/* RO over current active */
-#define	EHCI_PS_PEC		0x00000008	/* RWC port enable change */
-#define	EHCI_PS_PE		0x00000004	/* RW port enable */
-#define	EHCI_PS_CSC		0x00000002	/* RWC connect status change */
-#define	EHCI_PS_CS		0x00000001	/* RO connect status */
-#define	EHCI_PS_CLEAR		(EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
-
-#define	EHCI_USBMODE		0x68	/* RW USB Device mode register */
-#define	EHCI_UM_CM		0x00000003	/* R/WO Controller Mode */
-#define	EHCI_UM_CM_IDLE		0x0	/* Idle */
-#define	EHCI_UM_CM_HOST		0x3	/* Host Controller */
-#define	EHCI_UM_ES		0x00000004	/* R/WO Endian Select */
-#define	EHCI_UM_ES_LE		0x0	/* Little-endian byte alignment */
-#define	EHCI_UM_ES_BE		0x4	/* Big-endian byte alignment */
-#define	EHCI_UM_SDIS		0x00000010	/* R/WO Stream Disable Mode */
-
-#define	EHCI_PORT_RESET_COMPLETE	2	/* ms */
-
 /*
  * Alignment NOTE: structures must be aligned so that the hardware can index
  * without performing addition.

Modified: stable/8/sys/dev/usb/controller/ehci_ixp4xx.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci_ixp4xx.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ehci_ixp4xx.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Modified: stable/8/sys/dev/usb/controller/ehci_mbus.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci_mbus.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ehci_mbus.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Modified: stable/8/sys/dev/usb/controller/ehci_pci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci_pci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ehci_pci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	PCI_EHCI_VENDORID_ACERLABS	0x10b9
 #define	PCI_EHCI_VENDORID_AMD		0x1022

Copied: stable/8/sys/dev/usb/controller/ehcireg.h (from r198151, head/sys/dev/usb/controller/ehcireg.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/sys/dev/usb/controller/ehcireg.h	Thu Oct 29 23:25:52 2009	(r198659, copy of r198151, head/sys/dev/usb/controller/ehcireg.h)
@@ -0,0 +1,174 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _EHCIREG_H_
+#define	_EHCIREG_H_
+
+/* PCI config registers  */
+#define	PCI_CBMEM		0x10	/* configuration base MEM */
+#define	PCI_INTERFACE_EHCI	0x20
+#define	PCI_USBREV		0x60	/* RO USB protocol revision */
+#define	PCI_USB_REV_MASK	0xff
+#define	PCI_USB_REV_PRE_1_0	0x00
+#define	PCI_USB_REV_1_0		0x10
+#define	PCI_USB_REV_1_1		0x11
+#define	PCI_USB_REV_2_0		0x20
+#define	PCI_EHCI_FLADJ		0x61	/* RW Frame len adj, SOF=59488+6*fladj */
+#define	PCI_EHCI_PORTWAKECAP	0x62	/* RW Port wake caps (opt)  */
+
+/* EHCI Extended Capabilities */
+#define	EHCI_EC_LEGSUP		0x01
+#define	EHCI_EECP_NEXT(x)	(((x) >> 8) & 0xff)
+#define	EHCI_EECP_ID(x)		((x) & 0xff)
+
+/* Legacy support extended capability */
+#define	EHCI_LEGSUP_BIOS_SEM		0x02
+#define	EHCI_LEGSUP_OS_SEM		0x03
+#define	EHCI_LEGSUP_USBLEGCTLSTS	0x04
+
+/* EHCI capability registers */
+#define	EHCI_CAPLENGTH		0x00	/* RO Capability register length field */
+/* reserved			0x01 */
+#define	EHCI_HCIVERSION		0x02	/* RO Interface version number */
+#define	EHCI_HCSPARAMS		0x04	/* RO Structural parameters */
+#define	EHCI_HCS_DEBUGPORT(x)	(((x) >> 20) & 0xf)
+#define	EHCI_HCS_P_INDICATOR(x) ((x) & 0x10000)
+#define	EHCI_HCS_N_CC(x)	(((x) >> 12) & 0xf)	/* # of companion ctlrs */
+#define	EHCI_HCS_N_PCC(x)	(((x) >> 8) & 0xf)	/* # of ports per comp. */
+#define	EHCI_HCS_PPC(x)		((x) & 0x10)	/* port power control */
+#define	EHCI_HCS_N_PORTS(x)	((x) & 0xf)	/* # of ports */
+#define	EHCI_HCCPARAMS		0x08	/* RO Capability parameters */
+#define	EHCI_HCC_EECP(x)	(((x) >> 8) & 0xff)	/* extended ports caps */
+#define	EHCI_HCC_IST(x)		(((x) >> 4) & 0xf)	/* isoc sched threshold */
+#define	EHCI_HCC_ASPC(x)	((x) & 0x4)	/* async sched park cap */
+#define	EHCI_HCC_PFLF(x)	((x) & 0x2)	/* prog frame list flag */
+#define	EHCI_HCC_64BIT(x)	((x) & 0x1)	/* 64 bit address cap */
+#define	EHCI_HCSP_PORTROUTE	0x0c	/* RO Companion port route description */
+
+/* EHCI operational registers.  Offset given by EHCI_CAPLENGTH register */
+#define	EHCI_USBCMD		0x00	/* RO, RW, WO Command register */
+#define	EHCI_CMD_ITC_M		0x00ff0000	/* RW interrupt threshold ctrl */
+#define	EHCI_CMD_ITC_1		0x00010000
+#define	EHCI_CMD_ITC_2		0x00020000
+#define	EHCI_CMD_ITC_4		0x00040000
+#define	EHCI_CMD_ITC_8		0x00080000
+#define	EHCI_CMD_ITC_16		0x00100000
+#define	EHCI_CMD_ITC_32		0x00200000
+#define	EHCI_CMD_ITC_64		0x00400000
+#define	EHCI_CMD_ASPME		0x00000800	/* RW/RO async park enable */
+#define	EHCI_CMD_ASPMC		0x00000300	/* RW/RO async park count */
+#define	EHCI_CMD_LHCR		0x00000080	/* RW light host ctrl reset */
+#define	EHCI_CMD_IAAD		0x00000040	/* RW intr on async adv door
+						 * bell */
+#define	EHCI_CMD_ASE		0x00000020	/* RW async sched enable */
+#define	EHCI_CMD_PSE		0x00000010	/* RW periodic sched enable */
+#define	EHCI_CMD_FLS_M		0x0000000c	/* RW/RO frame list size */
+#define	EHCI_CMD_FLS(x)		(((x) >> 2) & 3)	/* RW/RO frame list size */
+#define	EHCI_CMD_HCRESET	0x00000002	/* RW reset */
+#define	EHCI_CMD_RS		0x00000001	/* RW run/stop */
+#define	EHCI_USBSTS		0x04	/* RO, RW, RWC Status register */
+#define	EHCI_STS_ASS		0x00008000	/* RO async sched status */
+#define	EHCI_STS_PSS		0x00004000	/* RO periodic sched status */
+#define	EHCI_STS_REC		0x00002000	/* RO reclamation */
+#define	EHCI_STS_HCH		0x00001000	/* RO host controller halted */
+#define	EHCI_STS_IAA		0x00000020	/* RWC interrupt on async adv */
+#define	EHCI_STS_HSE		0x00000010	/* RWC host system error */
+#define	EHCI_STS_FLR		0x00000008	/* RWC frame list rollover */
+#define	EHCI_STS_PCD		0x00000004	/* RWC port change detect */
+#define	EHCI_STS_ERRINT		0x00000002	/* RWC error interrupt */
+#define	EHCI_STS_INT		0x00000001	/* RWC interrupt */
+#define	EHCI_STS_INTRS(x)	((x) & 0x3f)
+
+/*
+ * NOTE: the doorbell interrupt is enabled, but the doorbell is never
+ * used! SiS chipsets require this.
+ */
+#define	EHCI_NORMAL_INTRS	(EHCI_STS_IAA | EHCI_STS_HSE |	\
+				EHCI_STS_PCD | EHCI_STS_ERRINT | EHCI_STS_INT)
+
+#define	EHCI_USBINTR		0x08	/* RW Interrupt register */
+#define	EHCI_INTR_IAAE		0x00000020	/* interrupt on async advance
+						 * ena */
+#define	EHCI_INTR_HSEE		0x00000010	/* host system error ena */
+#define	EHCI_INTR_FLRE		0x00000008	/* frame list rollover ena */
+#define	EHCI_INTR_PCIE		0x00000004	/* port change ena */
+#define	EHCI_INTR_UEIE		0x00000002	/* USB error intr ena */
+#define	EHCI_INTR_UIE		0x00000001	/* USB intr ena */
+
+#define	EHCI_FRINDEX		0x0c	/* RW Frame Index register */
+
+#define	EHCI_CTRLDSSEGMENT	0x10	/* RW Control Data Structure Segment */
+
+#define	EHCI_PERIODICLISTBASE	0x14	/* RW Periodic List Base */
+#define	EHCI_ASYNCLISTADDR	0x18	/* RW Async List Base */
+
+#define	EHCI_CONFIGFLAG		0x40	/* RW Configure Flag register */
+#define	EHCI_CONF_CF		0x00000001	/* RW configure flag */
+
+#define	EHCI_PORTSC(n)		(0x40+(4*(n)))	/* RO, RW, RWC Port Status reg */
+#define	EHCI_PS_WKOC_E		0x00400000	/* RW wake on over current ena */
+#define	EHCI_PS_WKDSCNNT_E	0x00200000	/* RW wake on disconnect ena */
+#define	EHCI_PS_WKCNNT_E	0x00100000	/* RW wake on connect ena */
+#define	EHCI_PS_PTC		0x000f0000	/* RW port test control */
+#define	EHCI_PS_PIC		0x0000c000	/* RW port indicator control */
+#define	EHCI_PS_PO		0x00002000	/* RW port owner */
+#define	EHCI_PS_PP		0x00001000	/* RW,RO port power */
+#define	EHCI_PS_LS		0x00000c00	/* RO line status */
+#define	EHCI_PS_IS_LOWSPEED(x)	(((x) & EHCI_PS_LS) == 0x00000400)
+#define	EHCI_PS_PR		0x00000100	/* RW port reset */
+#define	EHCI_PS_SUSP		0x00000080	/* RW suspend */
+#define	EHCI_PS_FPR		0x00000040	/* RW force port resume */
+#define	EHCI_PS_OCC		0x00000020	/* RWC over current change */
+#define	EHCI_PS_OCA		0x00000010	/* RO over current active */
+#define	EHCI_PS_PEC		0x00000008	/* RWC port enable change */
+#define	EHCI_PS_PE		0x00000004	/* RW port enable */
+#define	EHCI_PS_CSC		0x00000002	/* RWC connect status change */
+#define	EHCI_PS_CS		0x00000001	/* RO connect status */
+#define	EHCI_PS_CLEAR		(EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
+
+#define	EHCI_USBMODE		0x68	/* RW USB Device mode register */
+#define	EHCI_UM_CM		0x00000003	/* R/WO Controller Mode */
+#define	EHCI_UM_CM_IDLE		0x0	/* Idle */
+#define	EHCI_UM_CM_HOST		0x3	/* Host Controller */
+#define	EHCI_UM_ES		0x00000004	/* R/WO Endian Select */
+#define	EHCI_UM_ES_LE		0x0	/* Little-endian byte alignment */
+#define	EHCI_UM_ES_BE		0x4	/* Big-endian byte alignment */
+#define	EHCI_UM_SDIS		0x00000010	/* R/WO Stream Disable Mode */
+
+#define	EHCI_PORT_RESET_COMPLETE	2	/* ms */
+
+#endif	/* _EHCIREG_H_ */

Modified: stable/8/sys/dev/usb/controller/ohci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ohci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ohci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	OHCI_BUS2SC(bus) \
    ((ohci_softc_t *)(((uint8_t *)(bus)) - \

Modified: stable/8/sys/dev/usb/controller/ohci.h
==============================================================================
--- stable/8/sys/dev/usb/controller/ohci.h	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ohci.h	Thu Oct 29 23:25:52 2009	(r198659)
@@ -41,95 +41,6 @@
 
 #define	OHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128)
 
-/* PCI config registers  */
-#define	PCI_CBMEM		0x10	/* configuration base memory */
-#define	PCI_INTERFACE_OHCI	0x10
-
-/* OHCI registers */
-#define	OHCI_REVISION		0x00	/* OHCI revision */
-#define	OHCI_REV_LO(rev)	((rev) & 0xf)
-#define	OHCI_REV_HI(rev)	(((rev)>>4) & 0xf)
-#define	OHCI_REV_LEGACY(rev)	((rev) & 0x100)
-#define	OHCI_CONTROL		0x04
-#define	OHCI_CBSR_MASK		0x00000003	/* Control/Bulk Service Ratio */
-#define	OHCI_RATIO_1_1		0x00000000
-#define	OHCI_RATIO_1_2		0x00000001
-#define	OHCI_RATIO_1_3		0x00000002
-#define	OHCI_RATIO_1_4		0x00000003
-#define	OHCI_PLE		0x00000004	/* Periodic List Enable */
-#define	OHCI_IE			0x00000008	/* Isochronous Enable */
-#define	OHCI_CLE		0x00000010	/* Control List Enable */
-#define	OHCI_BLE		0x00000020	/* Bulk List Enable */
-#define	OHCI_HCFS_MASK		0x000000c0	/* HostControllerFunctionalStat
-						 * e */
-#define	OHCI_HCFS_RESET		0x00000000
-#define	OHCI_HCFS_RESUME	0x00000040
-#define	OHCI_HCFS_OPERATIONAL	0x00000080
-#define	OHCI_HCFS_SUSPEND	0x000000c0
-#define	OHCI_IR			0x00000100	/* Interrupt Routing */
-#define	OHCI_RWC		0x00000200	/* Remote Wakeup Connected */
-#define	OHCI_RWE		0x00000400	/* Remote Wakeup Enabled */
-#define	OHCI_COMMAND_STATUS	0x08
-#define	OHCI_HCR		0x00000001	/* Host Controller Reset */
-#define	OHCI_CLF		0x00000002	/* Control List Filled */
-#define	OHCI_BLF		0x00000004	/* Bulk List Filled */
-#define	OHCI_OCR		0x00000008	/* Ownership Change Request */
-#define	OHCI_SOC_MASK		0x00030000	/* Scheduling Overrun Count */
-#define	OHCI_INTERRUPT_STATUS	0x0c
-#define	OHCI_SO			0x00000001	/* Scheduling Overrun */
-#define	OHCI_WDH		0x00000002	/* Writeback Done Head */
-#define	OHCI_SF			0x00000004	/* Start of Frame */
-#define	OHCI_RD			0x00000008	/* Resume Detected */
-#define	OHCI_UE			0x00000010	/* Unrecoverable Error */
-#define	OHCI_FNO		0x00000020	/* Frame Number Overflow */
-#define	OHCI_RHSC		0x00000040	/* Root Hub Status Change */
-#define	OHCI_OC			0x40000000	/* Ownership Change */
-#define	OHCI_MIE		0x80000000	/* Master Interrupt Enable */
-#define	OHCI_INTERRUPT_ENABLE	0x10
-#define	OHCI_INTERRUPT_DISABLE	0x14
-#define	OHCI_HCCA		0x18
-#define	OHCI_PERIOD_CURRENT_ED	0x1c
-#define	OHCI_CONTROL_HEAD_ED	0x20
-#define	OHCI_CONTROL_CURRENT_ED	0x24
-#define	OHCI_BULK_HEAD_ED	0x28
-#define	OHCI_BULK_CURRENT_ED	0x2c
-#define	OHCI_DONE_HEAD		0x30
-#define	OHCI_FM_INTERVAL	0x34
-#define	OHCI_GET_IVAL(s)	((s) & 0x3fff)
-#define	OHCI_GET_FSMPS(s)	(((s) >> 16) & 0x7fff)
-#define	OHCI_FIT		0x80000000
-#define	OHCI_FM_REMAINING	0x38
-#define	OHCI_FM_NUMBER		0x3c
-#define	OHCI_PERIODIC_START	0x40
-#define	OHCI_LS_THRESHOLD	0x44
-#define	OHCI_RH_DESCRIPTOR_A	0x48
-#define	OHCI_GET_NDP(s)		((s) & 0xff)
-#define	OHCI_PSM		0x0100	/* Power Switching Mode */
-#define	OHCI_NPS		0x0200	/* No Power Switching */
-#define	OHCI_DT			0x0400	/* Device Type */
-#define	OHCI_OCPM		0x0800	/* Overcurrent Protection Mode */
-#define	OHCI_NOCP		0x1000	/* No Overcurrent Protection */
-#define	OHCI_GET_POTPGT(s)	((s) >> 24)
-#define	OHCI_RH_DESCRIPTOR_B	0x4c
-#define	OHCI_RH_STATUS		0x50
-#define	OHCI_LPS		0x00000001	/* Local Power Status */
-#define	OHCI_OCI		0x00000002	/* OverCurrent Indicator */
-#define	OHCI_DRWE		0x00008000	/* Device Remote Wakeup Enable */
-#define	OHCI_LPSC		0x00010000	/* Local Power Status Change */
-#define	OHCI_CCIC		0x00020000	/* OverCurrent Indicator
-						 * Change */
-#define	OHCI_CRWE		0x80000000	/* Clear Remote Wakeup Enable */
-#define	OHCI_RH_PORT_STATUS(n)	(0x50 + ((n)*4))	/* 1 based indexing */
-
-#define	OHCI_LES		(OHCI_PLE | OHCI_IE | OHCI_CLE | OHCI_BLE)
-#define	OHCI_ALL_INTRS		(OHCI_SO | OHCI_WDH | OHCI_SF |		\
-				OHCI_RD | OHCI_UE | OHCI_FNO |		\
-				OHCI_RHSC | OHCI_OC)
-#define	OHCI_NORMAL_INTRS	(OHCI_WDH | OHCI_RD | OHCI_UE | OHCI_RHSC)
-
-#define	OHCI_FSMPS(i)		(((i-210)*6/7) << 16)
-#define	OHCI_PERIODIC(i)	((i)*9/10)
-
 #define	OHCI_NO_INTRS		32
 #define	OHCI_HCCA_SIZE		256
 

Modified: stable/8/sys/dev/usb/controller/ohci_atmelarm.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ohci_atmelarm.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ohci_atmelarm.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 

Modified: stable/8/sys/dev/usb/controller/ohci_pci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ohci_pci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/ohci_pci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	PCI_OHCI_VENDORID_ACERLABS	0x10b9
 #define	PCI_OHCI_VENDORID_AMD		0x1022

Copied: stable/8/sys/dev/usb/controller/ohcireg.h (from r198151, head/sys/dev/usb/controller/ohcireg.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/sys/dev/usb/controller/ohcireg.h	Thu Oct 29 23:25:52 2009	(r198659, copy of r198151, head/sys/dev/usb/controller/ohcireg.h)
@@ -0,0 +1,131 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _OHCIREG_H_
+#define	_OHCIREG_H_
+
+/* PCI config registers  */
+#define	PCI_CBMEM		0x10	/* configuration base memory */
+#define	PCI_INTERFACE_OHCI	0x10
+
+/* OHCI registers */
+#define	OHCI_REVISION		0x00	/* OHCI revision */
+#define	OHCI_REV_LO(rev)	((rev) & 0xf)
+#define	OHCI_REV_HI(rev)	(((rev)>>4) & 0xf)
+#define	OHCI_REV_LEGACY(rev)	((rev) & 0x100)
+#define	OHCI_CONTROL		0x04
+#define	OHCI_CBSR_MASK		0x00000003	/* Control/Bulk Service Ratio */
+#define	OHCI_RATIO_1_1		0x00000000
+#define	OHCI_RATIO_1_2		0x00000001
+#define	OHCI_RATIO_1_3		0x00000002
+#define	OHCI_RATIO_1_4		0x00000003
+#define	OHCI_PLE		0x00000004	/* Periodic List Enable */
+#define	OHCI_IE			0x00000008	/* Isochronous Enable */
+#define	OHCI_CLE		0x00000010	/* Control List Enable */
+#define	OHCI_BLE		0x00000020	/* Bulk List Enable */
+#define	OHCI_HCFS_MASK		0x000000c0	/* HostControllerFunctionalStat
+						 * e */
+#define	OHCI_HCFS_RESET		0x00000000
+#define	OHCI_HCFS_RESUME	0x00000040
+#define	OHCI_HCFS_OPERATIONAL	0x00000080
+#define	OHCI_HCFS_SUSPEND	0x000000c0
+#define	OHCI_IR			0x00000100	/* Interrupt Routing */
+#define	OHCI_RWC		0x00000200	/* Remote Wakeup Connected */
+#define	OHCI_RWE		0x00000400	/* Remote Wakeup Enabled */
+#define	OHCI_COMMAND_STATUS	0x08
+#define	OHCI_HCR		0x00000001	/* Host Controller Reset */
+#define	OHCI_CLF		0x00000002	/* Control List Filled */
+#define	OHCI_BLF		0x00000004	/* Bulk List Filled */
+#define	OHCI_OCR		0x00000008	/* Ownership Change Request */
+#define	OHCI_SOC_MASK		0x00030000	/* Scheduling Overrun Count */
+#define	OHCI_INTERRUPT_STATUS	0x0c
+#define	OHCI_SO			0x00000001	/* Scheduling Overrun */
+#define	OHCI_WDH		0x00000002	/* Writeback Done Head */
+#define	OHCI_SF			0x00000004	/* Start of Frame */
+#define	OHCI_RD			0x00000008	/* Resume Detected */
+#define	OHCI_UE			0x00000010	/* Unrecoverable Error */
+#define	OHCI_FNO		0x00000020	/* Frame Number Overflow */
+#define	OHCI_RHSC		0x00000040	/* Root Hub Status Change */
+#define	OHCI_OC			0x40000000	/* Ownership Change */
+#define	OHCI_MIE		0x80000000	/* Master Interrupt Enable */
+#define	OHCI_INTERRUPT_ENABLE	0x10
+#define	OHCI_INTERRUPT_DISABLE	0x14
+#define	OHCI_HCCA		0x18
+#define	OHCI_PERIOD_CURRENT_ED	0x1c
+#define	OHCI_CONTROL_HEAD_ED	0x20
+#define	OHCI_CONTROL_CURRENT_ED	0x24
+#define	OHCI_BULK_HEAD_ED	0x28
+#define	OHCI_BULK_CURRENT_ED	0x2c
+#define	OHCI_DONE_HEAD		0x30
+#define	OHCI_FM_INTERVAL	0x34
+#define	OHCI_GET_IVAL(s)	((s) & 0x3fff)
+#define	OHCI_GET_FSMPS(s)	(((s) >> 16) & 0x7fff)
+#define	OHCI_FIT		0x80000000
+#define	OHCI_FM_REMAINING	0x38
+#define	OHCI_FM_NUMBER		0x3c
+#define	OHCI_PERIODIC_START	0x40
+#define	OHCI_LS_THRESHOLD	0x44
+#define	OHCI_RH_DESCRIPTOR_A	0x48
+#define	OHCI_GET_NDP(s)		((s) & 0xff)
+#define	OHCI_PSM		0x0100	/* Power Switching Mode */
+#define	OHCI_NPS		0x0200	/* No Power Switching */
+#define	OHCI_DT			0x0400	/* Device Type */
+#define	OHCI_OCPM		0x0800	/* Overcurrent Protection Mode */
+#define	OHCI_NOCP		0x1000	/* No Overcurrent Protection */
+#define	OHCI_GET_POTPGT(s)	((s) >> 24)
+#define	OHCI_RH_DESCRIPTOR_B	0x4c
+#define	OHCI_RH_STATUS		0x50
+#define	OHCI_LPS		0x00000001	/* Local Power Status */
+#define	OHCI_OCI		0x00000002	/* OverCurrent Indicator */
+#define	OHCI_DRWE		0x00008000	/* Device Remote Wakeup Enable */
+#define	OHCI_LPSC		0x00010000	/* Local Power Status Change */
+#define	OHCI_CCIC		0x00020000	/* OverCurrent Indicator
+						 * Change */
+#define	OHCI_CRWE		0x80000000	/* Clear Remote Wakeup Enable */
+#define	OHCI_RH_PORT_STATUS(n)	(0x50 + ((n)*4))	/* 1 based indexing */
+
+#define	OHCI_LES		(OHCI_PLE | OHCI_IE | OHCI_CLE | OHCI_BLE)
+#define	OHCI_ALL_INTRS		(OHCI_SO | OHCI_WDH | OHCI_SF |		\
+				OHCI_RD | OHCI_UE | OHCI_FNO |		\
+				OHCI_RHSC | OHCI_OC)
+#define	OHCI_NORMAL_INTRS	(OHCI_WDH | OHCI_RD | OHCI_UE | OHCI_RHSC)
+
+#define	OHCI_FSMPS(i)		(((i-210)*6/7) << 16)
+#define	OHCI_PERIODIC(i)	((i)*9/10)
+
+#endif	/* _OHCIREG_H_ */

Modified: stable/8/sys/dev/usb/controller/uhci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/uhci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/uhci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	alt_next next
 #define	UHCI_BUS2SC(bus) \

Modified: stable/8/sys/dev/usb/controller/uhci.h
==============================================================================
--- stable/8/sys/dev/usb/controller/uhci.h	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/uhci.h	Thu Oct 29 23:25:52 2009	(r198659)
@@ -41,64 +41,6 @@
 
 #define	UHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128)
 
-/* PCI config registers  */
-#define	PCI_USBREV		0x60	/* USB protocol revision */
-#define	PCI_USB_REV_MASK		0xff
-#define	PCI_USB_REV_PRE_1_0	0x00
-#define	PCI_USB_REV_1_0		0x10
-#define	PCI_USB_REV_1_1		0x11
-#define	PCI_LEGSUP		0xc0	/* Legacy Support register */
-#define	PCI_LEGSUP_USBPIRQDEN	0x2000	/* USB PIRQ D Enable */
-#define	PCI_CBIO		0x20	/* configuration base IO */
-#define	PCI_INTERFACE_UHCI	0x00
-
-/* UHCI registers */
-#define	UHCI_CMD		0x00
-#define	UHCI_CMD_RS		0x0001
-#define	UHCI_CMD_HCRESET	0x0002
-#define	UHCI_CMD_GRESET		0x0004
-#define	UHCI_CMD_EGSM		0x0008
-#define	UHCI_CMD_FGR		0x0010
-#define	UHCI_CMD_SWDBG		0x0020
-#define	UHCI_CMD_CF		0x0040
-#define	UHCI_CMD_MAXP		0x0080
-#define	UHCI_STS		0x02
-#define	UHCI_STS_USBINT		0x0001
-#define	UHCI_STS_USBEI		0x0002
-#define	UHCI_STS_RD		0x0004
-#define	UHCI_STS_HSE		0x0008
-#define	UHCI_STS_HCPE		0x0010
-#define	UHCI_STS_HCH		0x0020
-#define	UHCI_STS_ALLINTRS	0x003f
-#define	UHCI_INTR		0x04
-#define	UHCI_INTR_TOCRCIE	0x0001
-#define	UHCI_INTR_RIE		0x0002
-#define	UHCI_INTR_IOCE		0x0004
-#define	UHCI_INTR_SPIE		0x0008
-#define	UHCI_FRNUM		0x06
-#define	UHCI_FRNUM_MASK		0x03ff
-#define	UHCI_FLBASEADDR		0x08
-#define	UHCI_SOF		0x0c
-#define	UHCI_SOF_MASK		0x7f
-#define	UHCI_PORTSC1      	0x010
-#define	UHCI_PORTSC2      	0x012
-#define	UHCI_PORTSC_CCS		0x0001
-#define	UHCI_PORTSC_CSC		0x0002
-#define	UHCI_PORTSC_PE		0x0004
-#define	UHCI_PORTSC_POEDC	0x0008
-#define	UHCI_PORTSC_LS		0x0030
-#define	UHCI_PORTSC_LS_SHIFT	4
-#define	UHCI_PORTSC_RD		0x0040
-#define	UHCI_PORTSC_LSDA	0x0100
-#define	UHCI_PORTSC_PR		0x0200
-#define	UHCI_PORTSC_OCI		0x0400
-#define	UHCI_PORTSC_OCIC	0x0800
-#define	UHCI_PORTSC_SUSP	0x1000
-
-#define	URWMASK(x)		((x) & (UHCI_PORTSC_SUSP |		\
-				UHCI_PORTSC_PR | UHCI_PORTSC_RD |	\
-				UHCI_PORTSC_PE))
-
 #define	UHCI_FRAMELIST_COUNT	1024	/* units */
 #define	UHCI_FRAMELIST_ALIGN	4096	/* bytes */
 
@@ -118,8 +60,6 @@ typedef uint32_t uhci_physaddr_t;
 #define	UHCI_PTR_QH		0x00000002
 #define	UHCI_PTR_VF		0x00000004
 
-#define	UHCI_QH_REMOVE_DELAY	5	/* us - QH remove delay */
-
 /*
  * The Queue Heads (QH) and Transfer Descriptors (TD) are accessed by
  * both the CPU and the USB-controller which run concurrently. Great

Modified: stable/8/sys/dev/usb/controller/uhci_pci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/uhci_pci.c	Thu Oct 29 23:25:13 2009	(r198658)
+++ stable/8/sys/dev/usb/controller/uhci_pci.c	Thu Oct 29 23:25:52 2009	(r198659)
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #define	PCI_UHCI_VENDORID_INTEL		0x8086
 #define	PCI_UHCI_VENDORID_VIA		0x1106

Copied: stable/8/sys/dev/usb/controller/uhcireg.h (from r198151, head/sys/dev/usb/controller/uhcireg.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/sys/dev/usb/controller/uhcireg.h	Thu Oct 29 23:25:52 2009	(r198659, copy of r198151, head/sys/dev/usb/controller/uhcireg.h)
@@ -0,0 +1,100 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _UHCIREG_H_
+#define	_UHCIREG_H_
+
+/* PCI config registers  */
+#define	PCI_USBREV		0x60	/* USB protocol revision */
+#define	PCI_USB_REV_MASK		0xff
+#define	PCI_USB_REV_PRE_1_0	0x00
+#define	PCI_USB_REV_1_0		0x10
+#define	PCI_USB_REV_1_1		0x11
+#define	PCI_LEGSUP		0xc0	/* Legacy Support register */
+#define	PCI_LEGSUP_USBPIRQDEN	0x2000	/* USB PIRQ D Enable */
+#define	PCI_CBIO		0x20	/* configuration base IO */
+#define	PCI_INTERFACE_UHCI	0x00
+
+/* UHCI registers */
+#define	UHCI_CMD		0x00
+#define	UHCI_CMD_RS		0x0001
+#define	UHCI_CMD_HCRESET	0x0002
+#define	UHCI_CMD_GRESET		0x0004
+#define	UHCI_CMD_EGSM		0x0008
+#define	UHCI_CMD_FGR		0x0010
+#define	UHCI_CMD_SWDBG		0x0020
+#define	UHCI_CMD_CF		0x0040
+#define	UHCI_CMD_MAXP		0x0080
+#define	UHCI_STS		0x02
+#define	UHCI_STS_USBINT		0x0001
+#define	UHCI_STS_USBEI		0x0002
+#define	UHCI_STS_RD		0x0004
+#define	UHCI_STS_HSE		0x0008
+#define	UHCI_STS_HCPE		0x0010
+#define	UHCI_STS_HCH		0x0020
+#define	UHCI_STS_ALLINTRS	0x003f
+#define	UHCI_INTR		0x04
+#define	UHCI_INTR_TOCRCIE	0x0001
+#define	UHCI_INTR_RIE		0x0002
+#define	UHCI_INTR_IOCE		0x0004
+#define	UHCI_INTR_SPIE		0x0008
+#define	UHCI_FRNUM		0x06
+#define	UHCI_FRNUM_MASK		0x03ff
+#define	UHCI_FLBASEADDR		0x08
+#define	UHCI_SOF		0x0c
+#define	UHCI_SOF_MASK		0x7f
+#define	UHCI_PORTSC1      	0x010
+#define	UHCI_PORTSC2      	0x012
+#define	UHCI_PORTSC_CCS		0x0001
+#define	UHCI_PORTSC_CSC		0x0002
+#define	UHCI_PORTSC_PE		0x0004
+#define	UHCI_PORTSC_POEDC	0x0008
+#define	UHCI_PORTSC_LS		0x0030
+#define	UHCI_PORTSC_LS_SHIFT	4
+#define	UHCI_PORTSC_RD		0x0040
+#define	UHCI_PORTSC_LSDA	0x0100
+#define	UHCI_PORTSC_PR		0x0200
+#define	UHCI_PORTSC_OCI		0x0400
+#define	UHCI_PORTSC_OCIC	0x0800
+#define	UHCI_PORTSC_SUSP	0x1000
+
+#define	URWMASK(x)		((x) & (UHCI_PORTSC_SUSP |		\
+				UHCI_PORTSC_PR | UHCI_PORTSC_RD |	\
+				UHCI_PORTSC_PE))
+
+#endif	/* _UHCIREG_H_ */

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:26:30 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 680E31065697;
	Thu, 29 Oct 2009 23:26:30 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 521CE8FC2D;
	Thu, 29 Oct 2009 23:26:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNQUxm015800;
	Thu, 29 Oct 2009 23:26:30 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNQUl5015798;
	Thu, 29 Oct 2009 23:26:30 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292326.n9TNQUl5015798@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:26:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198660 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/input dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:26:30 -0000

Author: thompsa
Date: Thu Oct 29 23:26:29 2009
New Revision: 198660
URL: http://svn.freebsd.org/changeset/base/198660

Log:
  MFC r198152
  
   Only poll ukbd if KDB is active.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/input/ukbd.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/input/ukbd.c
==============================================================================
--- stable/8/sys/dev/usb/input/ukbd.c	Thu Oct 29 23:25:52 2009	(r198659)
+++ stable/8/sys/dev/usb/input/ukbd.c	Thu Oct 29 23:26:29 2009	(r198660)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -328,6 +329,9 @@ ukbd_do_poll(struct ukbd_softc *sc, uint
 {
 	DPRINTFN(2, "polling\n");
 
+	if (kdb_active == 0)
+		return;		/* Only poll if KDB is active */
+
 	while (sc->sc_inputs == 0) {
 
 		usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER);

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:27:01 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0673F10656A6;
	Thu, 29 Oct 2009 23:27:01 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BD08D8FC1A;
	Thu, 29 Oct 2009 23:27:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNR0fV015891;
	Thu, 29 Oct 2009 23:27:00 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNR0K4015889;
	Thu, 29 Oct 2009 23:27:00 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292327.n9TNR0K4015889@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:27:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198661 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/net dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:27:01 -0000

Author: thompsa
Date: Thu Oct 29 23:27:00 2009
New Revision: 198661
URL: http://svn.freebsd.org/changeset/base/198661

Log:
  MFC r198153
  
   Correct offset calcluation for the NCM implementation.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/net/if_cdce.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/net/if_cdce.c
==============================================================================
--- stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:26:29 2009	(r198660)
+++ stable/8/sys/dev/usb/net/if_cdce.c	Thu Oct 29 23:27:00 2009	(r198661)
@@ -1088,7 +1088,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer 
 	sc->sc_ncm.hdr.dwSignature[2] = 'M';
 	sc->sc_ncm.hdr.dwSignature[3] = 'H';
 	USETW(sc->sc_ncm.hdr.wHeaderLength, sizeof(sc->sc_ncm.hdr));
-	USETW(sc->sc_ncm.hdr.wBlockLength, offset);
+	USETW(sc->sc_ncm.hdr.wBlockLength, last_offset);
 	USETW(sc->sc_ncm.hdr.wSequence, sc->sc_ncm.tx_seq);
 	USETW(sc->sc_ncm.hdr.wDptIndex, sizeof(sc->sc_ncm.hdr));
 
@@ -1243,25 +1243,24 @@ cdce_ncm_bulk_read_callback(struct usb_x
 
 			offset = UGETW(sc->sc_ncm.dp[x].wFrameIndex);
 			temp = UGETW(sc->sc_ncm.dp[x].wFrameLength);
-			if ((offset + temp) > actlen) {
-				DPRINTFN(1, "invalid frame detected (ignored)\n");
-				m = NULL;
 
-			} else if (temp >= sizeof(struct ether_header)) {
-				/*
-				 * allocate a suitable memory buffer, if
-				 * possible
-				 */
-				if (temp > (MCLBYTES - ETHER_ALIGN)) {
-					m = NULL;
-					continue;
-				} if (temp > (MHLEN - ETHER_ALIGN)) {
-					m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
-				} else {
-					m = m_gethdr(M_DONTWAIT, MT_DATA);
-				}
+			if ((offset == 0) ||
+			    (temp < sizeof(struct ether_header)) ||
+			    (temp > (MCLBYTES - ETHER_ALIGN))) {
+				DPRINTFN(1, "NULL frame detected at %d\n", x);
+				m = NULL;
+				/* silently ignore this frame */
+				continue;
+			} else if ((offset + temp) > actlen) {
+				DPRINTFN(1, "invalid frame "
+				    "detected at %d\n", x);
+				m = NULL;
+				/* silently ignore this frame */
+				continue;
+			} else if (temp > (MHLEN - ETHER_ALIGN)) {
+				m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 			} else {
-				m = NULL;	/* dump it */
+				m = m_gethdr(M_DONTWAIT, MT_DATA);
 			}
 
 			DPRINTFN(16, "frame %u, offset = %u, length = %u \n",

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:27:40 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E47D4106566C;
	Thu, 29 Oct 2009 23:27:40 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CECB88FC13;
	Thu, 29 Oct 2009 23:27:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNReHA016003;
	Thu, 29 Oct 2009 23:27:40 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNRe1e016000;
	Thu, 29 Oct 2009 23:27:40 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292327.n9TNRe1e016000@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:27:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198662 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb dev/usb/serial dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:27:41 -0000

Author: thompsa
Date: Thu Oct 29 23:27:40 2009
New Revision: 198662
URL: http://svn.freebsd.org/changeset/base/198662

Log:
  MFC r198257
  
   Add support for newer WinChipHead CH341 chips, previously in the uch341 driver.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/serial/uchcom.c
  stable/8/sys/dev/usb/usbdevs
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/serial/uchcom.c
==============================================================================
--- stable/8/sys/dev/usb/serial/uchcom.c	Thu Oct 29 23:27:00 2009	(r198661)
+++ stable/8/sys/dev/usb/serial/uchcom.c	Thu Oct 29 23:27:40 2009	(r198662)
@@ -66,7 +66,8 @@
 __FBSDID("$FreeBSD$");
 
 /*
- * driver for WinChipHead CH341/340, the worst USB-serial chip in the world.
+ * Driver for WinChipHead CH341/340, the worst USB-serial chip in the
+ * world.
  */
 
 #include 
@@ -206,6 +207,7 @@ static const struct uchcom_divider_recor
 
 static const struct usb_device_id uchcom_devs[] = {
 	{USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)},
+	{USB_VPI(USB_VENDOR_WCH2, USB_PRODUCT_WCH2_CH341SER, 0)},
 };
 
 /* protypes */
@@ -213,6 +215,7 @@ static const struct usb_device_id uchcom
 static int	uchcom_pre_param(struct ucom_softc *, struct termios *);
 static void	uchcom_cfg_get_status(struct ucom_softc *, uint8_t *,
 		    uint8_t *);
+static void	uchcom_cfg_open(struct ucom_softc *ucom);
 static void	uchcom_cfg_param(struct ucom_softc *, struct termios *);
 static void	uchcom_cfg_set_break(struct ucom_softc *, uint8_t);
 static void	uchcom_cfg_set_dtr(struct ucom_softc *, uint8_t);
@@ -224,12 +227,9 @@ static void	uchcom_stop_write(struct uco
 static void	uchcom_update_version(struct uchcom_softc *);
 static void	uchcom_convert_status(struct uchcom_softc *, uint8_t);
 static void	uchcom_update_status(struct uchcom_softc *);
-static void	uchcom_set_dtrrts(struct uchcom_softc *);
+static void	uchcom_set_dtr_rts(struct uchcom_softc *);
 static int	uchcom_calc_divider_settings(struct uchcom_divider *, uint32_t);
-static void	uchcom_set_dte_rate(struct uchcom_softc *, uint32_t);
-static void	uchcom_set_line_control(struct uchcom_softc *, tcflag_t);
-static void	uchcom_clear_chip(struct uchcom_softc *);
-static void	uchcom_reset_chip(struct uchcom_softc *);
+static void	uchcom_set_baudrate(struct uchcom_softc *, uint32_t);
 static void	uchcom_poll(struct ucom_softc *ucom);
 
 static device_probe_t uchcom_probe;
@@ -275,6 +275,7 @@ static struct ucom_callback uchcom_callb
 	.ucom_cfg_set_dtr = &uchcom_cfg_set_dtr,
 	.ucom_cfg_set_rts = &uchcom_cfg_set_rts,
 	.ucom_cfg_set_break = &uchcom_cfg_set_break,
+	.ucom_cfg_open = &uchcom_cfg_open,
 	.ucom_cfg_param = &uchcom_cfg_param,
 	.ucom_pre_param = &uchcom_pre_param,
 	.ucom_start_read = &uchcom_start_read,
@@ -341,17 +342,6 @@ uchcom_attach(device_t dev)
 		    "error=%s\n", usbd_errstr(error));
 		goto detach;
 	}
-	/*
-	 * Do the initialization during attach so that the system does not
-	 * sleep during open:
-	 */
-	uchcom_update_version(sc);
-	uchcom_clear_chip(sc);
-	uchcom_reset_chip(sc);
-	uchcom_update_status(sc);
-
-	sc->sc_dtr = 1;
-	sc->sc_rts = 1;
 
 	/* clear stall at first run */
 	mtx_lock(&sc->sc_mtx);
@@ -458,8 +448,7 @@ uchcom_get_version(struct uchcom_softc *
 {
 	uint8_t buf[UCHCOM_INPUT_BUF_SIZE];
 
-	uchcom_ctrl_read(
-	    sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof(buf));
+	uchcom_ctrl_read(sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof(buf));
 
 	if (rver)
 		*rver = buf[0];
@@ -472,13 +461,13 @@ uchcom_get_status(struct uchcom_softc *s
 }
 
 static void
-uchcom_set_dtrrts_10(struct uchcom_softc *sc, uint8_t val)
+uchcom_set_dtr_rts_10(struct uchcom_softc *sc, uint8_t val)
 {
 	uchcom_write_reg(sc, UCHCOM_REG_STAT1, val, UCHCOM_REG_STAT1, val);
 }
 
 static void
-uchcom_set_dtrrts_20(struct uchcom_softc *sc, uint8_t val)
+uchcom_set_dtr_rts_20(struct uchcom_softc *sc, uint8_t val)
 {
 	uchcom_ctrl_write(sc, UCHCOM_REQ_SET_DTRRTS, val, 0);
 }
@@ -515,7 +504,7 @@ uchcom_update_status(struct uchcom_softc
 
 
 static void
-uchcom_set_dtrrts(struct uchcom_softc *sc)
+uchcom_set_dtr_rts(struct uchcom_softc *sc)
 {
 	uint8_t val = 0;
 
@@ -525,9 +514,9 @@ uchcom_set_dtrrts(struct uchcom_softc *s
 		val |= UCHCOM_RTS_MASK;
 
 	if (sc->sc_version < UCHCOM_VER_20)
-		uchcom_set_dtrrts_10(sc, ~val);
+		uchcom_set_dtr_rts_10(sc, ~val);
 	else
-		uchcom_set_dtrrts_20(sc, ~val);
+		uchcom_set_dtr_rts_20(sc, ~val);
 }
 
 static void
@@ -583,16 +572,16 @@ found:
 		dp->dv_div = (uint8_t)-div;
 	}
 
-	mod = UCHCOM_BPS_MOD_BASE / rate + UCHCOM_BPS_MOD_BASE_OFS;
-	mod = mod + mod / 2;
+	mod = (UCHCOM_BPS_MOD_BASE / rate) + UCHCOM_BPS_MOD_BASE_OFS;
+	mod = mod + (mod / 2);
 
-	dp->dv_mod = mod / 0x100;
+	dp->dv_mod = (mod + 0xFF) / 0x100;
 
 	return (0);
 }
 
 static void
-uchcom_set_dte_rate(struct uchcom_softc *sc, uint32_t rate)
+uchcom_set_baudrate(struct uchcom_softc *sc, uint32_t rate)
 {
 	struct uchcom_divider dv;
 
@@ -607,76 +596,6 @@ uchcom_set_dte_rate(struct uchcom_softc 
 	    UCHCOM_REG_BPS_PAD, 0);
 }
 
-static void
-uchcom_set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
-{
-	uint8_t lcr1 = 0;
-	uint8_t lcr2 = 0;
-
-	uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
-
-	lcr1 &= ~UCHCOM_LCR1_MASK;
-	lcr2 &= ~UCHCOM_LCR2_MASK;
-
-	/*
-	 * XXX: it is difficult to handle the line control appropriately:
-	 *   - CS8, !CSTOPB and any parity mode seems ok, but
-	 *   - the chip doesn't have the function to calculate parity
-	 *     in !CS8 mode.
-	 *   - it is unclear that the chip supports CS5,6 mode.
-	 *   - it is unclear how to handle stop bits.
-	 */
-
-	if (cflag & PARENB) {
-		lcr1 |= UCHCOM_LCR1_PARENB;
-		if (cflag & PARODD)
-			lcr2 |= UCHCOM_LCR2_PARODD;
-		else
-			lcr2 |= UCHCOM_LCR2_PAREVEN;
-	}
-	uchcom_write_reg(sc, UCHCOM_REG_LCR1, lcr1, UCHCOM_REG_LCR2, lcr2);
-}
-
-static void
-uchcom_clear_chip(struct uchcom_softc *sc)
-{
-	DPRINTF("\n");
-	uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0);
-}
-
-static void
-uchcom_reset_chip(struct uchcom_softc *sc)
-{
-	uint16_t val;
-	uint16_t idx;
-	uint8_t lcr1;
-	uint8_t lcr2;
-	uint8_t pre;
-	uint8_t div;
-	uint8_t mod;
-
-	uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
-	uchcom_read_reg(sc, UCHCOM_REG_BPS_PRE, &pre, UCHCOM_REG_BPS_DIV, &div);
-	uchcom_read_reg(sc, UCHCOM_REG_BPS_MOD, &mod, UCHCOM_REG_BPS_PAD, NULL);
-
-	val = 0;
-	idx = 0;
-	val |= (uint16_t)(lcr1 & 0xF0) << 8;
-	val |= 0x01;
-	val |= (uint16_t)(lcr2 & 0x0F) << 8;
-	val |= 0x02;
-	idx |= pre & 0x07;
-	val |= 0x04;
-	idx |= (uint16_t)div << 8;
-	val |= 0x08;
-	idx |= mod & 0xF8;
-	val |= 0x10;
-
-	DPRINTF("reset v=0x%04X, i=0x%04X\n", val, idx);
-
-	uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, val, idx);
-}
-
 /* ----------------------------------------------------------------------
  * methods for ucom
  */
@@ -699,7 +618,7 @@ uchcom_cfg_set_dtr(struct ucom_softc *uc
 	DPRINTF("onoff = %d\n", onoff);
 
 	sc->sc_dtr = onoff;
-	uchcom_set_dtrrts(sc);
+	uchcom_set_dtr_rts(sc);
 }
 
 static void
@@ -710,7 +629,18 @@ uchcom_cfg_set_rts(struct ucom_softc *uc
 	DPRINTF("onoff = %d\n", onoff);
 
 	sc->sc_rts = onoff;
-	uchcom_set_dtrrts(sc);
+	uchcom_set_dtr_rts(sc);
+}
+
+static void
+uchcom_cfg_open(struct ucom_softc *ucom)
+{
+	struct uchcom_softc *sc = ucom->sc_parent;
+
+	DPRINTF("\n");
+
+	uchcom_update_version(sc);
+	uchcom_update_status(sc);
 }
 
 static int
@@ -719,12 +649,10 @@ uchcom_pre_param(struct ucom_softc *ucom
 	struct uchcom_divider dv;
 
 	switch (t->c_cflag & CSIZE) {
-	case CS5:
-	case CS6:
-	case CS7:
-		return (EIO);
-	default:
+	case CS8:
 		break;
+	default:
+		return (EIO);
 	}
 
 	if (uchcom_calc_divider_settings(&dv, t->c_ospeed)) {
@@ -738,8 +666,16 @@ uchcom_cfg_param(struct ucom_softc *ucom
 {
 	struct uchcom_softc *sc = ucom->sc_parent;
 
-	uchcom_set_line_control(sc, t->c_cflag);
-	uchcom_set_dte_rate(sc, t->c_ospeed);
+	uchcom_get_version(sc, 0);
+	uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0);
+	uchcom_set_baudrate(sc, t->c_ospeed);
+	uchcom_read_reg(sc, 0x18, 0, 0x25, 0);
+	uchcom_write_reg(sc, 0x18, 0x50, 0x25, 0x00);
+	uchcom_update_status(sc);
+	uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0x501f, 0xd90a);
+	uchcom_set_baudrate(sc, t->c_ospeed);
+	uchcom_set_dtr_rts(sc);
+	uchcom_update_status(sc);
 }
 
 static void
@@ -840,14 +776,14 @@ uchcom_write_callback(struct usb_xfer *x
 tr_setup:
 		pc = usbd_xfer_get_frame(xfer, 0);
 		if (ucom_get_data(&sc->sc_ucom, pc, 0,
-		    UCHCOM_BULK_BUF_SIZE, &actlen)) {
+		    usbd_xfer_max_len(xfer), &actlen)) {
 
 			DPRINTF("actlen = %d\n", actlen);
 
 			usbd_xfer_set_frame_len(xfer, 0, actlen);
 			usbd_transfer_submit(xfer);
 		}
-		return;
+		break;
 
 	default:			/* Error */
 		if (error != USB_ERR_CANCELLED) {
@@ -855,8 +791,7 @@ tr_setup:
 			usbd_xfer_set_stall(xfer);
 			goto tr_setup;
 		}
-		return;
-
+		break;
 	}
 }
 
@@ -871,14 +806,17 @@ uchcom_read_callback(struct usb_xfer *xf
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
-		pc = usbd_xfer_get_frame(xfer, 0);
-		ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
+
+		if (actlen > 0) {
+			pc = usbd_xfer_get_frame(xfer, 0);
+			ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
+		}
 
 	case USB_ST_SETUP:
 tr_setup:
 		usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
 		usbd_transfer_submit(xfer);
-		return;
+		break;
 
 	default:			/* Error */
 		if (error != USB_ERR_CANCELLED) {
@@ -886,7 +824,7 @@ tr_setup:
 			usbd_xfer_set_stall(xfer);
 			goto tr_setup;
 		}
-		return;
+		break;
 	}
 }
 

Modified: stable/8/sys/dev/usb/usbdevs
==============================================================================
--- stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:27:00 2009	(r198661)
+++ stable/8/sys/dev/usb/usbdevs	Thu Oct 29 23:27:40 2009	(r198662)
@@ -626,6 +626,7 @@ vendor AMIT		0x18c5	AMIT
 vendor QCOM		0x18e8	Qcom
 vendor LINKSYS3		0x1915	Linksys
 vendor QUALCOMMINC	0x19d2	Qualcomm, Incorporated
+vendor WCH2		0x1a86	QinHeng Electronics
 vendor STELERA		0x1a8d	Stelera Wireless
 vendor MPMAN		0x1cae	MpMan
 vendor DRESDENELEKTRONIK 0x1cf1 dresden elektronik
@@ -2506,8 +2507,11 @@ product WACOM GRAPHIRE		0x0010	Graphire
 product WACOM GRAPHIRE3_4X5	0x0013	Graphire 3 4x5
 product WACOM INTUOSA5		0x0021	Intuos A5
 product WACOM GD0912U		0x0022	Intuos 9x12 Graphics Tablet
-/* WCH products*/
+
+/* WCH products */
 product WCH CH341SER		0x5523	CH341/CH340 USB-Serial Bridge
+product WCH2 CH341SER		0x7523	CH341/CH340 USB-Serial Bridge
+
 /* Western Digital products */
 product WESTERN COMBO		0x0200	Firewire USB Combo
 product WESTERN EXTHDD		0x0400	External HDD

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:28:21 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7C1FF1065692;
	Thu, 29 Oct 2009 23:28:21 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 67C038FC15;
	Thu, 29 Oct 2009 23:28:21 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNSLdx016112;
	Thu, 29 Oct 2009 23:28:21 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNSLxl016110;
	Thu, 29 Oct 2009 23:28:21 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292328.n9TNSLxl016110@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:28:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198663 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci modules/usb/ucom
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:28:21 -0000

Author: thompsa
Date: Thu Oct 29 23:28:21 2009
New Revision: 198663
URL: http://svn.freebsd.org/changeset/base/198663

Log:
  MFC r198258
  
   Add opt_gdb.h which is now needed by ucom.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/modules/usb/ucom/Makefile

Modified: stable/8/sys/modules/usb/ucom/Makefile
==============================================================================
--- stable/8/sys/modules/usb/ucom/Makefile	Thu Oct 29 23:27:40 2009	(r198662)
+++ stable/8/sys/modules/usb/ucom/Makefile	Thu Oct 29 23:28:21 2009	(r198663)
@@ -30,7 +30,7 @@ S=     ${.CURDIR}/../../..
 .PATH: $S/dev/usb/serial
 
 KMOD=	ucom
-SRCS=	opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
+SRCS=	opt_bus.h opt_usb.h opt_gdb.h device_if.h bus_if.h usb_if.h usbdevs.h \
 	usb_serial.c
 
 .include 

From owner-svn-src-stable@FreeBSD.ORG  Thu Oct 29 23:28:48 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C3E5410656A3;
	Thu, 29 Oct 2009 23:28:48 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AF34C8FC28;
	Thu, 29 Oct 2009 23:28:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TNSmKC016203;
	Thu, 29 Oct 2009 23:28:48 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TNSmOP016201;
	Thu, 29 Oct 2009 23:28:48 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200910292328.n9TNSmOP016201@svn.freebsd.org>
From: Andrew Thompson 
Date: Thu, 29 Oct 2009 23:28:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198664 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/usb/input dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 29 Oct 2009 23:28:49 -0000

Author: thompsa
Date: Thu Oct 29 23:28:48 2009
New Revision: 198664
URL: http://svn.freebsd.org/changeset/base/198664

Log:
  MFC r198373
  
   Allow dumping the USB mouse reports via 'sysctl -b dev.ums.N.parseinfo',
   previously only available via bootverbose.
  
  PR:		usb/137191

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/input/ums.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/input/ums.c
==============================================================================
--- stable/8/sys/dev/usb/input/ums.c	Thu Oct 29 23:28:21 2009	(r198663)
+++ stable/8/sys/dev/usb/input/ums.c	Thu Oct 29 23:28:48 2009	(r198664)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -161,7 +162,9 @@ static usb_fifo_open_t ums_open;
 static usb_fifo_close_t ums_close;
 static usb_fifo_ioctl_t ums_ioctl;
 
-static void ums_put_queue(struct ums_softc *sc, int32_t dx, int32_t dy, int32_t dz, int32_t dt, int32_t buttons);
+static void	ums_put_queue(struct ums_softc *, int32_t, int32_t,
+		    int32_t, int32_t, int32_t);
+static int	ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS);
 
 static struct usb_fifo_methods ums_fifo_methods = {
 	.f_open = &ums_open,
@@ -643,6 +646,12 @@ ums_attach(device_t dev)
 	if (err) {
 		goto detach;
 	}
+	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+	    OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD,
+	    sc, 0, ums_sysctl_handler_parseinfo,
+	    "", "Dump UMS report parsing information");
+
 	return (0);
 
 detach:
@@ -916,6 +925,67 @@ done:
 	return (error);
 }
 
+static int
+ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS)
+{
+	struct ums_softc *sc = arg1;
+	struct ums_info *info;
+	struct sbuf *sb;
+	int i, j, err;
+
+	sb = sbuf_new_auto();
+	for (i = 0; i < UMS_INFO_MAX; i++) {
+		info = &sc->sc_info[i];
+
+		/* Don't emit empty info */
+		if ((info->sc_flags &
+		    (UMS_FLAG_X_AXIS | UMS_FLAG_Y_AXIS | UMS_FLAG_Z_AXIS |
+		     UMS_FLAG_T_AXIS | UMS_FLAG_W_AXIS)) == 0 &&
+		    info->sc_buttons == 0)
+			continue;
+
+		sbuf_printf(sb, "i%d:", i + 1);
+		if (info->sc_flags & UMS_FLAG_X_AXIS)
+			sbuf_printf(sb, " X:r%d, p%d, s%d;",
+			    (int)info->sc_iid_x,
+			    (int)info->sc_loc_x.pos,
+			    (int)info->sc_loc_x.size);
+		if (info->sc_flags & UMS_FLAG_Y_AXIS)
+			sbuf_printf(sb, " Y:r%d, p%d, s%d;",
+			    (int)info->sc_iid_y,
+			    (int)info->sc_loc_y.pos,
+			    (int)info->sc_loc_y.size);
+		if (info->sc_flags & UMS_FLAG_Z_AXIS)
+			sbuf_printf(sb, " Z:r%d, p%d, s%d;",
+			    (int)info->sc_iid_z,
+			    (int)info->sc_loc_z.pos,
+			    (int)info->sc_loc_z.size);
+		if (info->sc_flags & UMS_FLAG_T_AXIS)
+			sbuf_printf(sb, " T:r%d, p%d, s%d;",
+			    (int)info->sc_iid_t,
+			    (int)info->sc_loc_t.pos,
+			    (int)info->sc_loc_t.size);
+		if (info->sc_flags & UMS_FLAG_W_AXIS)
+			sbuf_printf(sb, " W:r%d, p%d, s%d;",
+			    (int)info->sc_iid_w,
+			    (int)info->sc_loc_w.pos,
+			    (int)info->sc_loc_w.size);
+
+		for (j = 0; j < info->sc_buttons; j++) {
+			sbuf_printf(sb, " B%d:r%d, p%d, s%d;", j + 1,
+			    (int)info->sc_iid_btn[j],
+			    (int)info->sc_loc_btn[j].pos,
+			    (int)info->sc_loc_btn[j].size);
+		}
+		sbuf_printf(sb, "\n");
+	}
+	sbuf_finish(sb);
+	err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
+	sbuf_delete(sb);
+
+	return (err);
+}
+
 static devclass_t ums_devclass;
 
 static device_method_t ums_methods[] = {

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 12:57:28 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9570C106566C;
	Fri, 30 Oct 2009 12:57:28 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 824978FC12;
	Fri, 30 Oct 2009 12:57:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UCvSBA044861;
	Fri, 30 Oct 2009 12:57:28 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UCvSXv044855;
	Fri, 30 Oct 2009 12:57:28 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910301257.n9UCvSXv044855@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 30 Oct 2009 12:57:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198672 - stable/8/lib/libradius
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 12:57:28 -0000

Author: mav
Date: Fri Oct 30 12:57:28 2009
New Revision: 198672
URL: http://svn.freebsd.org/changeset/base/198672

Log:
  MFC rev. 197086:
  Add simple embedded RADIUS server support to libradius, by extending existing
  API, keeping backward compatibility.
  
  First consumer for this functionality is going to become forthcoming MPD-5.4,
  supporting CoA and DR of RFC 3576: Dynamic Authorization Extensions to RADIUS.

Modified:
  stable/8/lib/libradius/   (props changed)
  stable/8/lib/libradius/libradius.3
  stable/8/lib/libradius/radlib.c
  stable/8/lib/libradius/radlib.h
  stable/8/lib/libradius/radlib_private.h

Modified: stable/8/lib/libradius/libradius.3
==============================================================================
--- stable/8/lib/libradius/libradius.3	Fri Oct 30 11:13:00 2009	(r198671)
+++ stable/8/lib/libradius/libradius.3	Fri Oct 30 12:57:28 2009	(r198672)
@@ -1,4 +1,5 @@
 .\" Copyright 1998 Juniper Networks, Inc.
+.\" Copyright 2009 Alexander Motin .
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,12 +25,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 27, 2004
+.Dd August 5, 2009
 .Dt LIBRADIUS 3
 .Os
 .Sh NAME
 .Nm libradius
-.Nd RADIUS client library
+.Nd RADIUS client/server library
 .Sh SYNOPSIS
 .In radlib.h
 .Ft "struct rad_handle *"
@@ -46,6 +47,8 @@
 .Fn rad_continue_send_request "struct rad_handle *h" "int selected" "int *fd" "struct timeval *tv"
 .Ft int
 .Fn rad_create_request "struct rad_handle *h" "int code"
+.Ft int
+.Fn rad_create_response "struct rad_handle *h" "int code"
 .Ft "struct in_addr"
 .Fn rad_cvt_addr "const void *data"
 .Ft u_int32_t
@@ -79,7 +82,13 @@
 .Ft ssize_t
 .Fn rad_request_authenticator "struct rad_handle *h" "char *buf" "size_t len"
 .Ft int
+.Fn rad_receive_request "struct rad_handle *h"
+.Ft int
 .Fn rad_send_request "struct rad_handle *h"
+.Ft int
+.Fn rad_send_response "struct rad_handle *h"
+.Ft "struct rad_handle *"
+.Fn rad_server_open "int fd"
 .Ft "const char *"
 .Fn rad_server_secret "struct rad_handle *h"
 .Ft u_char *
@@ -91,16 +100,17 @@
 .Sh DESCRIPTION
 The
 .Nm
-library implements the client side of the Remote Authentication Dial
-In User Service (RADIUS).
+library implements the Remote Authentication Dial In User Service (RADIUS).
 RADIUS, defined in RFCs 2865 and 2866,
 allows clients to perform authentication and accounting by means of
 network requests to remote servers.
 .Ss Initialization
 To use the library, an application must first call
 .Fn rad_auth_open
-or
+,
 .Fn rad_acct_open
+or
+.Fn rad_server_open
 to obtain a
 .Vt "struct rad_handle *" ,
 which provides the context for subsequent operations.
@@ -108,8 +118,10 @@ The former function is used for RADIUS a
 latter is used for RADIUS accounting.
 Calls to
 .Fn rad_auth_open
-and
+,
 .Fn rad_acct_open
+and
+.Fn rad_server_open
 always succeed unless insufficient virtual memory is available.
 If
 the necessary memory cannot be allocated, the functions return
@@ -451,6 +463,25 @@ subsequent library calls using the same 
 .Ss Cleanup
 To free the resources used by the RADIUS library, call
 .Fn rad_close .
+.Ss Server operation
+Server mode operates much alike to client mode, except packet send and receieve
+steps are swapped. To operate as server you should obtain server context with
+.Fn rad_server_open
+function, passing opened and bound UDP socket file descriptor as argument.
+You should define allowed clients and their secrets using
+.Fn rad_add_server
+function. port, timeout and max_tries arguments are ignored in server mode.
+You should call
+.Fn rad_receive_request
+function to receive request from client. If you do not want to block on socket
+read, you are free to use any poll(), select() or non-blocking sockets for
+the socket.
+Received request can be parsed with same parsing functions as for client.
+To respond to the request you should call
+.Fn rad_create_response
+and fill response content with same packet writing functions as for client.
+When packet is ready, it should be sent with
+.Fn rad_send_response
 .Sh RETURN VALUES
 The following functions return a non-negative value on success.
 If
@@ -466,6 +497,8 @@ which can be retrieved using
 .It
 .Fn rad_create_request
 .It
+.Fn rad_create_response
+.It
 .Fn rad_get_attr
 .It
 .Fn rad_put_addr
@@ -483,6 +516,8 @@ which can be retrieved using
 .Fn rad_continue_send_request
 .It
 .Fn rad_send_request
+.It
+.Fn rad_send_response
 .El
 .Pp
 The following functions return a
@@ -499,6 +534,8 @@ without recording an error message.
 .It
 .Fn rad_auth_open
 .It
+.Fn rad_server_open
+.It
 .Fn rad_cvt_string
 .El
 .Pp
@@ -553,3 +590,5 @@ subsequently added the ability to perfor
 accounting.
 Later additions and changes by
 .An Michael Bretterklieber .
+Server mode support was added by
+.An Alexander Motin .

Modified: stable/8/lib/libradius/radlib.c
==============================================================================
--- stable/8/lib/libradius/radlib.c	Fri Oct 30 11:13:00 2009	(r198671)
+++ stable/8/lib/libradius/radlib.c	Fri Oct 30 12:57:28 2009	(r198672)
@@ -103,7 +103,7 @@ insert_scrambled_password(struct rad_han
 	srvp = &h->servers[srv];
 	padded_len = h->pass_len == 0 ? 16 : (h->pass_len+15) & ~0xf;
 
-	memcpy(md5, &h->request[POS_AUTH], LEN_AUTH);
+	memcpy(md5, &h->out[POS_AUTH], LEN_AUTH);
 	for (pos = 0;  pos < padded_len;  pos += 16) {
 		int i;
 
@@ -120,49 +120,55 @@ insert_scrambled_password(struct rad_han
 		 * in calculating the scrambler for next time.
 		 */
 		for (i = 0;  i < 16;  i++)
-			h->request[h->pass_pos + pos + i] =
+			h->out[h->pass_pos + pos + i] =
 			    md5[i] ^= h->pass[pos + i];
 	}
 }
 
 static void
-insert_request_authenticator(struct rad_handle *h, int srv)
+insert_request_authenticator(struct rad_handle *h, int resp)
 {
 	MD5_CTX ctx;
 	const struct rad_server *srvp;
 
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	/* Create the request authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, memset(&h->request[POS_AUTH], 0, LEN_AUTH), LEN_AUTH);
-	MD5Update(&ctx, &h->request[POS_ATTRS], h->req_len - POS_ATTRS);
+	MD5Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+	if (resp)
+	    MD5Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+	else
+	    MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->out[POS_ATTRS], h->out_len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
-	MD5Final(&h->request[POS_AUTH], &ctx);
+	MD5Final(&h->out[POS_AUTH], &ctx);
 }
 
 static void
-insert_message_authenticator(struct rad_handle *h, int srv)
+insert_message_authenticator(struct rad_handle *h, int resp)
 {
 #ifdef WITH_SSL
 	u_char md[EVP_MAX_MD_SIZE];
 	u_int md_len;
 	const struct rad_server *srvp;
 	HMAC_CTX ctx;
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	if (h->authentic_pos != 0) {
 		HMAC_CTX_init(&ctx);
 		HMAC_Init(&ctx, srvp->secret, strlen(srvp->secret), EVP_md5());
-		HMAC_Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-		HMAC_Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-		HMAC_Update(&ctx, &h->request[POS_ATTRS],
-		    h->req_len - POS_ATTRS);
+		HMAC_Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+		if (resp)
+		    HMAC_Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+		else
+		    HMAC_Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+		HMAC_Update(&ctx, &h->out[POS_ATTRS],
+		    h->out_len - POS_ATTRS);
 		HMAC_Final(&ctx, md, &md_len);
 		HMAC_CTX_cleanup(&ctx);
 		HMAC_cleanup(&ctx);
-		memcpy(&h->request[h->authentic_pos + 2], md, md_len);
+		memcpy(&h->out[h->authentic_pos + 2], md, md_len);
 	}
 #endif
 }
@@ -195,20 +201,20 @@ is_valid_response(struct rad_handle *h, 
 		return 0;
 
 	/* Check the message length */
-	if (h->resp_len < POS_ATTRS)
+	if (h->in_len < POS_ATTRS)
 		return 0;
-	len = h->response[POS_LENGTH] << 8 | h->response[POS_LENGTH+1];
-	if (len > h->resp_len)
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
 		return 0;
 
 	/* Check the response authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->response[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-	MD5Update(&ctx, &h->response[POS_ATTRS], len - POS_ATTRS);
+	MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+	MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
 	MD5Final(md5, &ctx);
-	if (memcmp(&h->response[POS_AUTH], md5, sizeof md5) != 0)
+	if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
 		return 0;
 
 #ifdef WITH_SSL
@@ -216,42 +222,111 @@ is_valid_response(struct rad_handle *h, 
 	 * For non accounting responses check the message authenticator,
 	 * if any.
 	 */
-	if (h->response[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
+	if (h->in[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
 
-		memcpy(resp, h->response, MSGSIZE);
+		memcpy(resp, h->in, MSGSIZE);
 		pos = POS_ATTRS;
 
 		/* Search and verify the Message-Authenticator */
 		while (pos < len - 2) {
 
-			if (h->response[pos] == RAD_MESSAGE_AUTHENTIC) {
+			if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
 				/* zero fill the Message-Authenticator */
 				memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
 
 				HMAC_CTX_init(&hctx);
 				HMAC_Init(&hctx, srvp->secret,
 				    strlen(srvp->secret), EVP_md5());
-				HMAC_Update(&hctx, &h->response[POS_CODE],
+				HMAC_Update(&hctx, &h->in[POS_CODE],
 				    POS_AUTH - POS_CODE);
-				HMAC_Update(&hctx, &h->request[POS_AUTH],
+				HMAC_Update(&hctx, &h->out[POS_AUTH],
 				    LEN_AUTH);
 				HMAC_Update(&hctx, &resp[POS_ATTRS],
-				    h->resp_len - POS_ATTRS);
+				    h->in_len - POS_ATTRS);
 				HMAC_Final(&hctx, md, &md_len);
 				HMAC_CTX_cleanup(&hctx);
 				HMAC_cleanup(&hctx);
-				if (memcmp(md, &h->response[pos + 2],
+				if (memcmp(md, &h->in[pos + 2],
 				    MD5_DIGEST_LENGTH) != 0)
 					return 0;
 				break;
 			}
-			pos += h->response[pos + 1];
+			pos += h->in[pos + 1];
 		}
 	}
 #endif
 	return 1;
 }
 
+/*
+ * Return true if the current request is valid for the specified server.
+ */
+static int
+is_valid_request(struct rad_handle *h)
+{
+	MD5_CTX ctx;
+	unsigned char md5[MD5_DIGEST_LENGTH];
+	const struct rad_server *srvp;
+	int len;
+#ifdef WITH_SSL
+	HMAC_CTX hctx;
+	u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
+	u_int md_len;
+	int pos;
+#endif
+
+	srvp = &h->servers[h->srv];
+
+	/* Check the message length */
+	if (h->in_len < POS_ATTRS)
+		return (0);
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
+		return (0);
+
+	if (h->in[POS_CODE] != RAD_ACCESS_REQUEST) {
+		uint32_t zeroes[4] = { 0, 0, 0, 0 };
+		/* Check the request authenticator */
+		MD5Init(&ctx);
+		MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+		MD5Update(&ctx, zeroes, LEN_AUTH);
+		MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
+		MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
+		MD5Final(md5, &ctx);
+		if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
+			return (0);
+	}
+
+#ifdef WITH_SSL
+	/* Search and verify the Message-Authenticator */
+	pos = POS_ATTRS;
+	while (pos < len - 2) {
+		if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
+			memcpy(resp, h->in, MSGSIZE);
+			/* zero fill the Request-Authenticator */
+			if (h->in[POS_CODE] != RAD_ACCESS_REQUEST)
+				memset(&resp[POS_AUTH], 0, LEN_AUTH);
+			/* zero fill the Message-Authenticator */
+			memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
+
+			HMAC_CTX_init(&hctx);
+			HMAC_Init(&hctx, srvp->secret,
+			    strlen(srvp->secret), EVP_md5());
+			HMAC_Update(&hctx, resp, h->in_len);
+			HMAC_Final(&hctx, md, &md_len);
+			HMAC_CTX_cleanup(&hctx);
+			HMAC_cleanup(&hctx);
+			if (memcmp(md, &h->in[pos + 2],
+			    MD5_DIGEST_LENGTH) != 0)
+				return (0);
+			break;
+		}
+		pos += h->in[pos + 1];
+	}
+#endif
+	return (1);
+}
+
 static int
 put_password_attr(struct rad_handle *h, int type, const void *value, size_t len)
 {
@@ -273,7 +348,7 @@ put_password_attr(struct rad_handle *h, 
 	 */
 	clear_password(h);
 	put_raw_attr(h, type, h->pass, padded_len);
-	h->pass_pos = h->req_len - padded_len;
+	h->pass_pos = h->out_len - padded_len;
 
 	/* Save the cleartext password, padded as necessary */
 	memcpy(h->pass, value, len);
@@ -289,14 +364,14 @@ put_raw_attr(struct rad_handle *h, int t
 		generr(h, "Attribute too long");
 		return -1;
 	}
-	if (h->req_len + 2 + len > MSGSIZE) {
+	if (h->out_len + 2 + len > MSGSIZE) {
 		generr(h, "Maximum message length exceeded");
 		return -1;
 	}
-	h->request[h->req_len++] = type;
-	h->request[h->req_len++] = len + 2;
-	memcpy(&h->request[h->req_len], value, len);
-	h->req_len += len;
+	h->out[h->out_len++] = type;
+	h->out[h->out_len++] = len + 2;
+	memcpy(&h->out[h->out_len], value, len);
+	h->out_len += len;
 	return 0;
 }
 
@@ -523,22 +598,26 @@ rad_continue_send_request(struct rad_han
 {
 	int n;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	if (selected) {
 		struct sockaddr_in from;
 		socklen_t fromlen;
 
 		fromlen = sizeof from;
-		h->resp_len = recvfrom(h->fd, h->response,
+		h->in_len = recvfrom(h->fd, h->in,
 		    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
-		if (h->resp_len == -1) {
+		if (h->in_len == -1) {
 			generr(h, "recvfrom: %s", strerror(errno));
 			return -1;
 		}
 		if (is_valid_response(h, h->srv, &from)) {
-			h->resp_len = h->response[POS_LENGTH] << 8 |
-			    h->response[POS_LENGTH+1];
-			h->resp_pos = POS_ATTRS;
-			return h->response[POS_CODE];
+			h->in_len = h->in[POS_LENGTH] << 8 |
+			    h->in[POS_LENGTH+1];
+			h->in_pos = POS_ATTRS;
+			return h->in[POS_CODE];
 		}
 	}
 
@@ -556,21 +635,22 @@ rad_continue_send_request(struct rad_han
 		if (++h->srv >= h->num_servers)
 			h->srv = 0;
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST)
-		/* Insert the request authenticator into the request */
-		insert_request_authenticator(h, h->srv);
-	else
+	if (h->out[POS_CODE] == RAD_ACCESS_REQUEST) {
 		/* Insert the scrambled password into the request */
 		if (h->pass_pos != 0)
 			insert_scrambled_password(h, h->srv);
-
-	insert_message_authenticator(h, h->srv);
+	}
+	insert_message_authenticator(h, 0);
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
+		/* Insert the request authenticator into the request */
+		insert_request_authenticator(h, h->srv);
+	}
 
 	/* Send the request */
-	n = sendto(h->fd, h->request, h->req_len, 0,
+	n = sendto(h->fd, h->out, h->out_len, 0,
 	    (const struct sockaddr *)&h->servers[h->srv].addr,
 	    sizeof h->servers[h->srv].addr);
-	if (n != h->req_len) {
+	if (n != h->out_len) {
 		if (n == -1)
 			generr(h, "sendto: %s", strerror(errno));
 		else
@@ -588,22 +668,117 @@ rad_continue_send_request(struct rad_han
 }
 
 int
+rad_receive_request(struct rad_handle *h)
+{
+	struct sockaddr_in from;
+	socklen_t fromlen;
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->srv = -1;
+	fromlen = sizeof(from);
+	h->in_len = recvfrom(h->fd, h->in,
+	    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
+	if (h->in_len == -1) {
+		generr(h, "recvfrom: %s", strerror(errno));
+		return (-1);
+	}
+	for (n = 0; n < h->num_servers; n++) {
+		if (h->servers[n].addr.sin_addr.s_addr == from.sin_addr.s_addr) {
+			h->servers[n].addr.sin_port = from.sin_port;
+			h->srv = n;
+			break;
+		}
+	}
+	if (h->srv == -1)
+		return (-2);
+	if (is_valid_request(h)) {
+		h->in_len = h->in[POS_LENGTH] << 8 |
+		    h->in[POS_LENGTH+1];
+		h->in_pos = POS_ATTRS;
+		return (h->in[POS_CODE]);
+	}
+	return (-3);
+}
+
+int
+rad_send_response(struct rad_handle *h)
+{
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	/* Fill in the length field in the message */
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
+
+	insert_message_authenticator(h,
+	    (h->in[POS_CODE] == RAD_ACCESS_REQUEST) ? 1 : 0);
+	insert_request_authenticator(h, 1);
+
+	/* Send the request */
+	n = sendto(h->fd, h->out, h->out_len, 0,
+	    (const struct sockaddr *)&h->servers[h->srv].addr,
+	    sizeof h->servers[h->srv].addr);
+	if (n != h->out_len) {
+		if (n == -1)
+			generr(h, "sendto: %s", strerror(errno));
+		else
+			generr(h, "sendto: short write");
+		return -1;
+	}
+
+	return 0;
+}
+
+int
 rad_create_request(struct rad_handle *h, int code)
 {
 	int i;
 
-	h->request[POS_CODE] = code;
-	h->request[POS_IDENT] = ++h->ident;
-	/* Create a random authenticator */
-	for (i = 0;  i < LEN_AUTH;  i += 2) {
-		long r;
-		r = random();
-		h->request[POS_AUTH+i] = (u_char)r;
-		h->request[POS_AUTH+i+1] = (u_char)(r >> 8);
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = ++h->ident;
+	if (code == RAD_ACCESS_REQUEST) {
+		/* Create a random authenticator */
+		for (i = 0;  i < LEN_AUTH;  i += 2) {
+			long r;
+			r = random();
+			h->out[POS_AUTH+i] = (u_char)r;
+			h->out[POS_AUTH+i+1] = (u_char)(r >> 8);
+		}
+	} else
+		memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
+	clear_password(h);
+	h->authentic_pos = 0;
+	h->out_created = 1;
+	return 0;
+}
+
+int
+rad_create_response(struct rad_handle *h, int code)
+{
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
 	}
-	h->req_len = POS_ATTRS;
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = h->in[POS_IDENT];
+	memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
 	clear_password(h);
-	h->request_created = 1;
+	h->authentic_pos = 0;
+	h->out_created = 1;
 	return 0;
 }
 
@@ -647,20 +822,20 @@ rad_get_attr(struct rad_handle *h, const
 {
 	int type;
 
-	if (h->resp_pos >= h->resp_len)
+	if (h->in_pos >= h->in_len)
 		return 0;
-	if (h->resp_pos + 2 > h->resp_len) {
+	if (h->in_pos + 2 > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	type = h->response[h->resp_pos++];
-	*len = h->response[h->resp_pos++] - 2;
-	if (h->resp_pos + (int)*len > h->resp_len) {
+	type = h->in[h->in_pos++];
+	*len = h->in[h->in_pos++] - 2;
+	if (h->in_pos + (int)*len > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	*value = &h->response[h->resp_pos];
-	h->resp_pos += *len;
+	*value = &h->in[h->in_pos];
+	h->in_pos += *len;
 	return type;
 }
 
@@ -672,6 +847,10 @@ rad_init_send_request(struct rad_handle 
 {
 	int srv;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	/* Make sure we have a socket to use */
 	if (h->fd == -1) {
 		struct sockaddr_in sin;
@@ -694,7 +873,7 @@ rad_init_send_request(struct rad_handle 
 		}
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
 		/* Make sure no password given */
 		if (h->pass_pos || h->chap_pass) {
 			generr(h, "User or Chap Password"
@@ -718,8 +897,8 @@ rad_init_send_request(struct rad_handle 
 	}
 
 	/* Fill in the length field in the message */
-	h->request[POS_LENGTH] = h->req_len >> 8;
-	h->request[POS_LENGTH+1] = h->req_len;
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
 
 	/*
 	 * Count the total number of tries we will make, and zero the
@@ -763,7 +942,7 @@ rad_auth_open(void)
 		h->chap_pass = 0;
 		h->authentic_pos = 0;
 		h->type = RADIUS_AUTH;
-		h->request_created = 0;
+		h->out_created = 0;
 		h->eap_msg = 0;
 	}
 	return h;
@@ -781,6 +960,19 @@ rad_acct_open(void)
 }
 
 struct rad_handle *
+rad_server_open(int fd)
+{
+	struct rad_handle *h;
+
+	h = rad_open();
+	if (h != NULL) {
+	        h->type = RADIUS_SERVER;
+	        h->fd = fd;
+	}
+	return h;
+}
+
+struct rad_handle *
 rad_open(void)
 {
     return rad_auth_open();
@@ -797,13 +989,13 @@ rad_put_attr(struct rad_handle *h, int t
 {
 	int result;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		if (type == RAD_EAP_MESSAGE) {
 			generr(h, "EAP-Message attribute is not valid"
 			    " in accounting requests");
@@ -858,14 +1050,14 @@ rad_put_message_authentic(struct rad_han
 #ifdef WITH_SSL
 	u_char md_zero[MD5_DIGEST_LENGTH];
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		generr(h, "Message-Authenticator is not valid"
 		    " in accounting requests");
 		return -1;
 	}
 
 	if (h->authentic_pos == 0) {
-		h->authentic_pos = h->req_len;
+		h->authentic_pos = h->out_len;
 		memset(md_zero, 0, sizeof(md_zero));
 		return (put_raw_attr(h, RAD_MESSAGE_AUTHENTIC, md_zero,
 		    sizeof(md_zero)));
@@ -1041,7 +1233,7 @@ rad_put_vendor_attr(struct rad_handle *h
 	struct vendor_attribute *attr;
 	int res;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
@@ -1088,7 +1280,7 @@ rad_request_authenticator(struct rad_han
 {
 	if (len < LEN_AUTH)
 		return (-1);
-	memcpy(buf, h->request + POS_AUTH, LEN_AUTH);
+	memcpy(buf, h->out + POS_AUTH, LEN_AUTH);
 	if (len > LEN_AUTH)
 		buf[LEN_AUTH] = '\0';
 	return (LEN_AUTH);

Modified: stable/8/lib/libradius/radlib.h
==============================================================================
--- stable/8/lib/libradius/radlib.h	Fri Oct 30 11:13:00 2009	(r198671)
+++ stable/8/lib/libradius/radlib.h	Fri Oct 30 12:57:28 2009	(r198672)
@@ -42,6 +42,12 @@
 #define RAD_ACCOUNTING_REQUEST		4
 #define RAD_ACCOUNTING_RESPONSE		5
 #define RAD_ACCESS_CHALLENGE		11
+#define RAD_DISCONNECT_REQUEST		40
+#define RAD_DISCONNECT_ACK		41
+#define RAD_DISCONNECT_NAK		42
+#define RAD_COA_REQUEST			43
+#define RAD_COA_ACK			44
+#define RAD_COA_NAK			45
 
 /* Attribute types and values */
 #define RAD_USER_NAME			1	/* String */
@@ -179,6 +185,8 @@
 #define	RAD_ACCT_MULTI_SESSION_ID	50	/* String */
 #define	RAD_ACCT_LINK_COUNT		51	/* Integer */
 
+#define	RAD_ERROR_CAUSE			101	/* Integer */
+
 struct rad_handle;
 struct timeval;
 
@@ -192,6 +200,7 @@ int			 rad_config(struct rad_handle *, c
 int			 rad_continue_send_request(struct rad_handle *, int,
 			    int *, struct timeval *);
 int			 rad_create_request(struct rad_handle *, int);
+int			 rad_create_response(struct rad_handle *, int);
 struct in_addr		 rad_cvt_addr(const void *);
 u_int32_t		 rad_cvt_int(const void *);
 char			*rad_cvt_string(const void *, size_t);
@@ -209,7 +218,10 @@ int			 rad_put_string(struct rad_handle 
 int			 rad_put_message_authentic(struct rad_handle *);
 ssize_t			 rad_request_authenticator(struct rad_handle *, char *,
 			    size_t);
+int			 rad_receive_request(struct rad_handle *);
 int			 rad_send_request(struct rad_handle *);
+int			 rad_send_response(struct rad_handle *);
+struct rad_handle	*rad_server_open(int fd);
 const char		*rad_server_secret(struct rad_handle *);
 const char		*rad_strerror(struct rad_handle *);
 u_char			*rad_demangle(struct rad_handle *, const void *,

Modified: stable/8/lib/libradius/radlib_private.h
==============================================================================
--- stable/8/lib/libradius/radlib_private.h	Fri Oct 30 11:13:00 2009	(r198671)
+++ stable/8/lib/libradius/radlib_private.h	Fri Oct 30 12:57:28 2009	(r198672)
@@ -38,6 +38,7 @@
 /* Handle types */
 #define RADIUS_AUTH		0   /* RADIUS authentication, default */
 #define RADIUS_ACCT		1   /* RADIUS accounting */
+#define RADIUS_SERVER		2   /* RADIUS server */
 
 /* Defaults */
 #define MAXTRIES		3
@@ -75,18 +76,18 @@ struct rad_handle {
 	int		 num_servers;	/* Number of valid server entries */
 	int		 ident;		/* Current identifier value */
 	char		 errmsg[ERRSIZE];	/* Most recent error message */
-	unsigned char	 request[MSGSIZE];	/* Request to send */
-	char	 	 request_created; /* rad_create_request() called? */
-	int		 req_len;	/* Length of request */
+	unsigned char	 out[MSGSIZE];	/* Request to send */
+	char		 out_created;	/* rad_create_request() called? */
+	int		 out_len;	/* Length of request */
 	char		 pass[PASSSIZE];	/* Cleartext password */
 	int		 pass_len;	/* Length of cleartext password */
 	int		 pass_pos;	/* Position of scrambled password */
-	char	 	 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
+	char		 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
 	int		 authentic_pos;	/* Position of message authenticator */
 	char		 eap_msg;	/* Are we an EAP Proxy? */
-	unsigned char	 response[MSGSIZE];	/* Response received */
-	int		 resp_len;	/* Length of response */
-	int		 resp_pos;	/* Current position scanning attrs */
+	unsigned char	 in[MSGSIZE];	/* Response received */
+	int		 in_len;	/* Length of response */
+	int		 in_pos;	/* Current position scanning attrs */
 	int		 total_tries;	/* How many requests we'll send */
 	int		 try;		/* How many requests we've sent */
 	int		 srv;		/* Server number we did last */

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 12:59:23 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 409B5106568B;
	Fri, 30 Oct 2009 12:59:23 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2D8A28FC13;
	Fri, 30 Oct 2009 12:59:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UCxNh4044975;
	Fri, 30 Oct 2009 12:59:23 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UCxNIs044970;
	Fri, 30 Oct 2009 12:59:23 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910301259.n9UCxNIs044970@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 30 Oct 2009 12:59:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198673 - stable/7/lib/libradius
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 12:59:23 -0000

Author: mav
Date: Fri Oct 30 12:59:22 2009
New Revision: 198673
URL: http://svn.freebsd.org/changeset/base/198673

Log:
  MFC rev. 197086:
  Add simple embedded RADIUS server support to libradius, by extending existing
  API, keeping backward compatibility.
  
  First consumer for this functionality is going to become forthcoming MPD-5.4,
  supporting CoA and DR of RFC 3576: Dynamic Authorization Extensions to RADIUS.

Modified:
  stable/7/lib/libradius/   (props changed)
  stable/7/lib/libradius/libradius.3
  stable/7/lib/libradius/radlib.c
  stable/7/lib/libradius/radlib.h
  stable/7/lib/libradius/radlib_private.h

Modified: stable/7/lib/libradius/libradius.3
==============================================================================
--- stable/7/lib/libradius/libradius.3	Fri Oct 30 12:57:28 2009	(r198672)
+++ stable/7/lib/libradius/libradius.3	Fri Oct 30 12:59:22 2009	(r198673)
@@ -1,4 +1,5 @@
 .\" Copyright 1998 Juniper Networks, Inc.
+.\" Copyright 2009 Alexander Motin .
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,12 +25,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 27, 2004
+.Dd August 5, 2009
 .Dt LIBRADIUS 3
 .Os
 .Sh NAME
 .Nm libradius
-.Nd RADIUS client library
+.Nd RADIUS client/server library
 .Sh SYNOPSIS
 .In radlib.h
 .Ft "struct rad_handle *"
@@ -46,6 +47,8 @@
 .Fn rad_continue_send_request "struct rad_handle *h" "int selected" "int *fd" "struct timeval *tv"
 .Ft int
 .Fn rad_create_request "struct rad_handle *h" "int code"
+.Ft int
+.Fn rad_create_response "struct rad_handle *h" "int code"
 .Ft "struct in_addr"
 .Fn rad_cvt_addr "const void *data"
 .Ft u_int32_t
@@ -79,7 +82,13 @@
 .Ft ssize_t
 .Fn rad_request_authenticator "struct rad_handle *h" "char *buf" "size_t len"
 .Ft int
+.Fn rad_receive_request "struct rad_handle *h"
+.Ft int
 .Fn rad_send_request "struct rad_handle *h"
+.Ft int
+.Fn rad_send_response "struct rad_handle *h"
+.Ft "struct rad_handle *"
+.Fn rad_server_open "int fd"
 .Ft "const char *"
 .Fn rad_server_secret "struct rad_handle *h"
 .Ft u_char *
@@ -91,16 +100,17 @@
 .Sh DESCRIPTION
 The
 .Nm
-library implements the client side of the Remote Authentication Dial
-In User Service (RADIUS).
+library implements the Remote Authentication Dial In User Service (RADIUS).
 RADIUS, defined in RFCs 2865 and 2866,
 allows clients to perform authentication and accounting by means of
 network requests to remote servers.
 .Ss Initialization
 To use the library, an application must first call
 .Fn rad_auth_open
-or
+,
 .Fn rad_acct_open
+or
+.Fn rad_server_open
 to obtain a
 .Vt "struct rad_handle *" ,
 which provides the context for subsequent operations.
@@ -108,8 +118,10 @@ The former function is used for RADIUS a
 latter is used for RADIUS accounting.
 Calls to
 .Fn rad_auth_open
-and
+,
 .Fn rad_acct_open
+and
+.Fn rad_server_open
 always succeed unless insufficient virtual memory is available.
 If
 the necessary memory cannot be allocated, the functions return
@@ -451,6 +463,25 @@ subsequent library calls using the same 
 .Ss Cleanup
 To free the resources used by the RADIUS library, call
 .Fn rad_close .
+.Ss Server operation
+Server mode operates much alike to client mode, except packet send and receieve
+steps are swapped. To operate as server you should obtain server context with
+.Fn rad_server_open
+function, passing opened and bound UDP socket file descriptor as argument.
+You should define allowed clients and their secrets using
+.Fn rad_add_server
+function. port, timeout and max_tries arguments are ignored in server mode.
+You should call
+.Fn rad_receive_request
+function to receive request from client. If you do not want to block on socket
+read, you are free to use any poll(), select() or non-blocking sockets for
+the socket.
+Received request can be parsed with same parsing functions as for client.
+To respond to the request you should call
+.Fn rad_create_response
+and fill response content with same packet writing functions as for client.
+When packet is ready, it should be sent with
+.Fn rad_send_response
 .Sh RETURN VALUES
 The following functions return a non-negative value on success.
 If
@@ -466,6 +497,8 @@ which can be retrieved using
 .It
 .Fn rad_create_request
 .It
+.Fn rad_create_response
+.It
 .Fn rad_get_attr
 .It
 .Fn rad_put_addr
@@ -483,6 +516,8 @@ which can be retrieved using
 .Fn rad_continue_send_request
 .It
 .Fn rad_send_request
+.It
+.Fn rad_send_response
 .El
 .Pp
 The following functions return a
@@ -499,6 +534,8 @@ without recording an error message.
 .It
 .Fn rad_auth_open
 .It
+.Fn rad_server_open
+.It
 .Fn rad_cvt_string
 .El
 .Pp
@@ -553,3 +590,5 @@ subsequently added the ability to perfor
 accounting.
 Later additions and changes by
 .An Michael Bretterklieber .
+Server mode support was added by
+.An Alexander Motin .

Modified: stable/7/lib/libradius/radlib.c
==============================================================================
--- stable/7/lib/libradius/radlib.c	Fri Oct 30 12:57:28 2009	(r198672)
+++ stable/7/lib/libradius/radlib.c	Fri Oct 30 12:59:22 2009	(r198673)
@@ -103,7 +103,7 @@ insert_scrambled_password(struct rad_han
 	srvp = &h->servers[srv];
 	padded_len = h->pass_len == 0 ? 16 : (h->pass_len+15) & ~0xf;
 
-	memcpy(md5, &h->request[POS_AUTH], LEN_AUTH);
+	memcpy(md5, &h->out[POS_AUTH], LEN_AUTH);
 	for (pos = 0;  pos < padded_len;  pos += 16) {
 		int i;
 
@@ -120,49 +120,55 @@ insert_scrambled_password(struct rad_han
 		 * in calculating the scrambler for next time.
 		 */
 		for (i = 0;  i < 16;  i++)
-			h->request[h->pass_pos + pos + i] =
+			h->out[h->pass_pos + pos + i] =
 			    md5[i] ^= h->pass[pos + i];
 	}
 }
 
 static void
-insert_request_authenticator(struct rad_handle *h, int srv)
+insert_request_authenticator(struct rad_handle *h, int resp)
 {
 	MD5_CTX ctx;
 	const struct rad_server *srvp;
 
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	/* Create the request authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, memset(&h->request[POS_AUTH], 0, LEN_AUTH), LEN_AUTH);
-	MD5Update(&ctx, &h->request[POS_ATTRS], h->req_len - POS_ATTRS);
+	MD5Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+	if (resp)
+	    MD5Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+	else
+	    MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->out[POS_ATTRS], h->out_len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
-	MD5Final(&h->request[POS_AUTH], &ctx);
+	MD5Final(&h->out[POS_AUTH], &ctx);
 }
 
 static void
-insert_message_authenticator(struct rad_handle *h, int srv)
+insert_message_authenticator(struct rad_handle *h, int resp)
 {
 #ifdef WITH_SSL
 	u_char md[EVP_MAX_MD_SIZE];
 	u_int md_len;
 	const struct rad_server *srvp;
 	HMAC_CTX ctx;
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	if (h->authentic_pos != 0) {
 		HMAC_CTX_init(&ctx);
 		HMAC_Init(&ctx, srvp->secret, strlen(srvp->secret), EVP_md5());
-		HMAC_Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-		HMAC_Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-		HMAC_Update(&ctx, &h->request[POS_ATTRS],
-		    h->req_len - POS_ATTRS);
+		HMAC_Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+		if (resp)
+		    HMAC_Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+		else
+		    HMAC_Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+		HMAC_Update(&ctx, &h->out[POS_ATTRS],
+		    h->out_len - POS_ATTRS);
 		HMAC_Final(&ctx, md, &md_len);
 		HMAC_CTX_cleanup(&ctx);
 		HMAC_cleanup(&ctx);
-		memcpy(&h->request[h->authentic_pos + 2], md, md_len);
+		memcpy(&h->out[h->authentic_pos + 2], md, md_len);
 	}
 #endif
 }
@@ -195,20 +201,20 @@ is_valid_response(struct rad_handle *h, 
 		return 0;
 
 	/* Check the message length */
-	if (h->resp_len < POS_ATTRS)
+	if (h->in_len < POS_ATTRS)
 		return 0;
-	len = h->response[POS_LENGTH] << 8 | h->response[POS_LENGTH+1];
-	if (len > h->resp_len)
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
 		return 0;
 
 	/* Check the response authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->response[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-	MD5Update(&ctx, &h->response[POS_ATTRS], len - POS_ATTRS);
+	MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+	MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
 	MD5Final(md5, &ctx);
-	if (memcmp(&h->response[POS_AUTH], md5, sizeof md5) != 0)
+	if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
 		return 0;
 
 #ifdef WITH_SSL
@@ -216,42 +222,111 @@ is_valid_response(struct rad_handle *h, 
 	 * For non accounting responses check the message authenticator,
 	 * if any.
 	 */
-	if (h->response[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
+	if (h->in[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
 
-		memcpy(resp, h->response, MSGSIZE);
+		memcpy(resp, h->in, MSGSIZE);
 		pos = POS_ATTRS;
 
 		/* Search and verify the Message-Authenticator */
 		while (pos < len - 2) {
 
-			if (h->response[pos] == RAD_MESSAGE_AUTHENTIC) {
+			if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
 				/* zero fill the Message-Authenticator */
 				memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
 
 				HMAC_CTX_init(&hctx);
 				HMAC_Init(&hctx, srvp->secret,
 				    strlen(srvp->secret), EVP_md5());
-				HMAC_Update(&hctx, &h->response[POS_CODE],
+				HMAC_Update(&hctx, &h->in[POS_CODE],
 				    POS_AUTH - POS_CODE);
-				HMAC_Update(&hctx, &h->request[POS_AUTH],
+				HMAC_Update(&hctx, &h->out[POS_AUTH],
 				    LEN_AUTH);
 				HMAC_Update(&hctx, &resp[POS_ATTRS],
-				    h->resp_len - POS_ATTRS);
+				    h->in_len - POS_ATTRS);
 				HMAC_Final(&hctx, md, &md_len);
 				HMAC_CTX_cleanup(&hctx);
 				HMAC_cleanup(&hctx);
-				if (memcmp(md, &h->response[pos + 2],
+				if (memcmp(md, &h->in[pos + 2],
 				    MD5_DIGEST_LENGTH) != 0)
 					return 0;
 				break;
 			}
-			pos += h->response[pos + 1];
+			pos += h->in[pos + 1];
 		}
 	}
 #endif
 	return 1;
 }
 
+/*
+ * Return true if the current request is valid for the specified server.
+ */
+static int
+is_valid_request(struct rad_handle *h)
+{
+	MD5_CTX ctx;
+	unsigned char md5[MD5_DIGEST_LENGTH];
+	const struct rad_server *srvp;
+	int len;
+#ifdef WITH_SSL
+	HMAC_CTX hctx;
+	u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
+	u_int md_len;
+	int pos;
+#endif
+
+	srvp = &h->servers[h->srv];
+
+	/* Check the message length */
+	if (h->in_len < POS_ATTRS)
+		return (0);
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
+		return (0);
+
+	if (h->in[POS_CODE] != RAD_ACCESS_REQUEST) {
+		uint32_t zeroes[4] = { 0, 0, 0, 0 };
+		/* Check the request authenticator */
+		MD5Init(&ctx);
+		MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+		MD5Update(&ctx, zeroes, LEN_AUTH);
+		MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
+		MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
+		MD5Final(md5, &ctx);
+		if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
+			return (0);
+	}
+
+#ifdef WITH_SSL
+	/* Search and verify the Message-Authenticator */
+	pos = POS_ATTRS;
+	while (pos < len - 2) {
+		if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
+			memcpy(resp, h->in, MSGSIZE);
+			/* zero fill the Request-Authenticator */
+			if (h->in[POS_CODE] != RAD_ACCESS_REQUEST)
+				memset(&resp[POS_AUTH], 0, LEN_AUTH);
+			/* zero fill the Message-Authenticator */
+			memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
+
+			HMAC_CTX_init(&hctx);
+			HMAC_Init(&hctx, srvp->secret,
+			    strlen(srvp->secret), EVP_md5());
+			HMAC_Update(&hctx, resp, h->in_len);
+			HMAC_Final(&hctx, md, &md_len);
+			HMAC_CTX_cleanup(&hctx);
+			HMAC_cleanup(&hctx);
+			if (memcmp(md, &h->in[pos + 2],
+			    MD5_DIGEST_LENGTH) != 0)
+				return (0);
+			break;
+		}
+		pos += h->in[pos + 1];
+	}
+#endif
+	return (1);
+}
+
 static int
 put_password_attr(struct rad_handle *h, int type, const void *value, size_t len)
 {
@@ -273,7 +348,7 @@ put_password_attr(struct rad_handle *h, 
 	 */
 	clear_password(h);
 	put_raw_attr(h, type, h->pass, padded_len);
-	h->pass_pos = h->req_len - padded_len;
+	h->pass_pos = h->out_len - padded_len;
 
 	/* Save the cleartext password, padded as necessary */
 	memcpy(h->pass, value, len);
@@ -289,14 +364,14 @@ put_raw_attr(struct rad_handle *h, int t
 		generr(h, "Attribute too long");
 		return -1;
 	}
-	if (h->req_len + 2 + len > MSGSIZE) {
+	if (h->out_len + 2 + len > MSGSIZE) {
 		generr(h, "Maximum message length exceeded");
 		return -1;
 	}
-	h->request[h->req_len++] = type;
-	h->request[h->req_len++] = len + 2;
-	memcpy(&h->request[h->req_len], value, len);
-	h->req_len += len;
+	h->out[h->out_len++] = type;
+	h->out[h->out_len++] = len + 2;
+	memcpy(&h->out[h->out_len], value, len);
+	h->out_len += len;
 	return 0;
 }
 
@@ -523,22 +598,26 @@ rad_continue_send_request(struct rad_han
 {
 	int n;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	if (selected) {
 		struct sockaddr_in from;
 		socklen_t fromlen;
 
 		fromlen = sizeof from;
-		h->resp_len = recvfrom(h->fd, h->response,
+		h->in_len = recvfrom(h->fd, h->in,
 		    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
-		if (h->resp_len == -1) {
+		if (h->in_len == -1) {
 			generr(h, "recvfrom: %s", strerror(errno));
 			return -1;
 		}
 		if (is_valid_response(h, h->srv, &from)) {
-			h->resp_len = h->response[POS_LENGTH] << 8 |
-			    h->response[POS_LENGTH+1];
-			h->resp_pos = POS_ATTRS;
-			return h->response[POS_CODE];
+			h->in_len = h->in[POS_LENGTH] << 8 |
+			    h->in[POS_LENGTH+1];
+			h->in_pos = POS_ATTRS;
+			return h->in[POS_CODE];
 		}
 	}
 
@@ -556,21 +635,22 @@ rad_continue_send_request(struct rad_han
 		if (++h->srv >= h->num_servers)
 			h->srv = 0;
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST)
-		/* Insert the request authenticator into the request */
-		insert_request_authenticator(h, h->srv);
-	else
+	if (h->out[POS_CODE] == RAD_ACCESS_REQUEST) {
 		/* Insert the scrambled password into the request */
 		if (h->pass_pos != 0)
 			insert_scrambled_password(h, h->srv);
-
-	insert_message_authenticator(h, h->srv);
+	}
+	insert_message_authenticator(h, 0);
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
+		/* Insert the request authenticator into the request */
+		insert_request_authenticator(h, h->srv);
+	}
 
 	/* Send the request */
-	n = sendto(h->fd, h->request, h->req_len, 0,
+	n = sendto(h->fd, h->out, h->out_len, 0,
 	    (const struct sockaddr *)&h->servers[h->srv].addr,
 	    sizeof h->servers[h->srv].addr);
-	if (n != h->req_len) {
+	if (n != h->out_len) {
 		if (n == -1)
 			generr(h, "sendto: %s", strerror(errno));
 		else
@@ -588,22 +668,117 @@ rad_continue_send_request(struct rad_han
 }
 
 int
+rad_receive_request(struct rad_handle *h)
+{
+	struct sockaddr_in from;
+	socklen_t fromlen;
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->srv = -1;
+	fromlen = sizeof(from);
+	h->in_len = recvfrom(h->fd, h->in,
+	    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
+	if (h->in_len == -1) {
+		generr(h, "recvfrom: %s", strerror(errno));
+		return (-1);
+	}
+	for (n = 0; n < h->num_servers; n++) {
+		if (h->servers[n].addr.sin_addr.s_addr == from.sin_addr.s_addr) {
+			h->servers[n].addr.sin_port = from.sin_port;
+			h->srv = n;
+			break;
+		}
+	}
+	if (h->srv == -1)
+		return (-2);
+	if (is_valid_request(h)) {
+		h->in_len = h->in[POS_LENGTH] << 8 |
+		    h->in[POS_LENGTH+1];
+		h->in_pos = POS_ATTRS;
+		return (h->in[POS_CODE]);
+	}
+	return (-3);
+}
+
+int
+rad_send_response(struct rad_handle *h)
+{
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	/* Fill in the length field in the message */
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
+
+	insert_message_authenticator(h,
+	    (h->in[POS_CODE] == RAD_ACCESS_REQUEST) ? 1 : 0);
+	insert_request_authenticator(h, 1);
+
+	/* Send the request */
+	n = sendto(h->fd, h->out, h->out_len, 0,
+	    (const struct sockaddr *)&h->servers[h->srv].addr,
+	    sizeof h->servers[h->srv].addr);
+	if (n != h->out_len) {
+		if (n == -1)
+			generr(h, "sendto: %s", strerror(errno));
+		else
+			generr(h, "sendto: short write");
+		return -1;
+	}
+
+	return 0;
+}
+
+int
 rad_create_request(struct rad_handle *h, int code)
 {
 	int i;
 
-	h->request[POS_CODE] = code;
-	h->request[POS_IDENT] = ++h->ident;
-	/* Create a random authenticator */
-	for (i = 0;  i < LEN_AUTH;  i += 2) {
-		long r;
-		r = random();
-		h->request[POS_AUTH+i] = (u_char)r;
-		h->request[POS_AUTH+i+1] = (u_char)(r >> 8);
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = ++h->ident;
+	if (code == RAD_ACCESS_REQUEST) {
+		/* Create a random authenticator */
+		for (i = 0;  i < LEN_AUTH;  i += 2) {
+			long r;
+			r = random();
+			h->out[POS_AUTH+i] = (u_char)r;
+			h->out[POS_AUTH+i+1] = (u_char)(r >> 8);
+		}
+	} else
+		memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
+	clear_password(h);
+	h->authentic_pos = 0;
+	h->out_created = 1;
+	return 0;
+}
+
+int
+rad_create_response(struct rad_handle *h, int code)
+{
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
 	}
-	h->req_len = POS_ATTRS;
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = h->in[POS_IDENT];
+	memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
 	clear_password(h);
-	h->request_created = 1;
+	h->authentic_pos = 0;
+	h->out_created = 1;
 	return 0;
 }
 
@@ -647,20 +822,20 @@ rad_get_attr(struct rad_handle *h, const
 {
 	int type;
 
-	if (h->resp_pos >= h->resp_len)
+	if (h->in_pos >= h->in_len)
 		return 0;
-	if (h->resp_pos + 2 > h->resp_len) {
+	if (h->in_pos + 2 > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	type = h->response[h->resp_pos++];
-	*len = h->response[h->resp_pos++] - 2;
-	if (h->resp_pos + (int)*len > h->resp_len) {
+	type = h->in[h->in_pos++];
+	*len = h->in[h->in_pos++] - 2;
+	if (h->in_pos + (int)*len > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	*value = &h->response[h->resp_pos];
-	h->resp_pos += *len;
+	*value = &h->in[h->in_pos];
+	h->in_pos += *len;
 	return type;
 }
 
@@ -672,6 +847,10 @@ rad_init_send_request(struct rad_handle 
 {
 	int srv;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	/* Make sure we have a socket to use */
 	if (h->fd == -1) {
 		struct sockaddr_in sin;
@@ -694,7 +873,7 @@ rad_init_send_request(struct rad_handle 
 		}
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
 		/* Make sure no password given */
 		if (h->pass_pos || h->chap_pass) {
 			generr(h, "User or Chap Password"
@@ -718,8 +897,8 @@ rad_init_send_request(struct rad_handle 
 	}
 
 	/* Fill in the length field in the message */
-	h->request[POS_LENGTH] = h->req_len >> 8;
-	h->request[POS_LENGTH+1] = h->req_len;
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
 
 	/*
 	 * Count the total number of tries we will make, and zero the
@@ -763,7 +942,7 @@ rad_auth_open(void)
 		h->chap_pass = 0;
 		h->authentic_pos = 0;
 		h->type = RADIUS_AUTH;
-		h->request_created = 0;
+		h->out_created = 0;
 		h->eap_msg = 0;
 	}
 	return h;
@@ -781,6 +960,19 @@ rad_acct_open(void)
 }
 
 struct rad_handle *
+rad_server_open(int fd)
+{
+	struct rad_handle *h;
+
+	h = rad_open();
+	if (h != NULL) {
+	        h->type = RADIUS_SERVER;
+	        h->fd = fd;
+	}
+	return h;
+}
+
+struct rad_handle *
 rad_open(void)
 {
     return rad_auth_open();
@@ -797,13 +989,13 @@ rad_put_attr(struct rad_handle *h, int t
 {
 	int result;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		if (type == RAD_EAP_MESSAGE) {
 			generr(h, "EAP-Message attribute is not valid"
 			    " in accounting requests");
@@ -858,14 +1050,14 @@ rad_put_message_authentic(struct rad_han
 #ifdef WITH_SSL
 	u_char md_zero[MD5_DIGEST_LENGTH];
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		generr(h, "Message-Authenticator is not valid"
 		    " in accounting requests");
 		return -1;
 	}
 
 	if (h->authentic_pos == 0) {
-		h->authentic_pos = h->req_len;
+		h->authentic_pos = h->out_len;
 		memset(md_zero, 0, sizeof(md_zero));
 		return (put_raw_attr(h, RAD_MESSAGE_AUTHENTIC, md_zero,
 		    sizeof(md_zero)));
@@ -1041,7 +1233,7 @@ rad_put_vendor_attr(struct rad_handle *h
 	struct vendor_attribute *attr;
 	int res;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
@@ -1088,7 +1280,7 @@ rad_request_authenticator(struct rad_han
 {
 	if (len < LEN_AUTH)
 		return (-1);
-	memcpy(buf, h->request + POS_AUTH, LEN_AUTH);
+	memcpy(buf, h->out + POS_AUTH, LEN_AUTH);
 	if (len > LEN_AUTH)
 		buf[LEN_AUTH] = '\0';
 	return (LEN_AUTH);

Modified: stable/7/lib/libradius/radlib.h
==============================================================================
--- stable/7/lib/libradius/radlib.h	Fri Oct 30 12:57:28 2009	(r198672)
+++ stable/7/lib/libradius/radlib.h	Fri Oct 30 12:59:22 2009	(r198673)
@@ -42,6 +42,12 @@
 #define RAD_ACCOUNTING_REQUEST		4
 #define RAD_ACCOUNTING_RESPONSE		5
 #define RAD_ACCESS_CHALLENGE		11
+#define RAD_DISCONNECT_REQUEST		40
+#define RAD_DISCONNECT_ACK		41
+#define RAD_DISCONNECT_NAK		42
+#define RAD_COA_REQUEST			43
+#define RAD_COA_ACK			44
+#define RAD_COA_NAK			45
 
 /* Attribute types and values */
 #define RAD_USER_NAME			1	/* String */
@@ -179,6 +185,8 @@
 #define	RAD_ACCT_MULTI_SESSION_ID	50	/* String */
 #define	RAD_ACCT_LINK_COUNT		51	/* Integer */
 
+#define	RAD_ERROR_CAUSE			101	/* Integer */
+
 struct rad_handle;
 struct timeval;
 
@@ -192,6 +200,7 @@ int			 rad_config(struct rad_handle *, c
 int			 rad_continue_send_request(struct rad_handle *, int,
 			    int *, struct timeval *);
 int			 rad_create_request(struct rad_handle *, int);
+int			 rad_create_response(struct rad_handle *, int);
 struct in_addr		 rad_cvt_addr(const void *);
 u_int32_t		 rad_cvt_int(const void *);
 char			*rad_cvt_string(const void *, size_t);
@@ -209,7 +218,10 @@ int			 rad_put_string(struct rad_handle 
 int			 rad_put_message_authentic(struct rad_handle *);
 ssize_t			 rad_request_authenticator(struct rad_handle *, char *,
 			    size_t);
+int			 rad_receive_request(struct rad_handle *);
 int			 rad_send_request(struct rad_handle *);
+int			 rad_send_response(struct rad_handle *);
+struct rad_handle	*rad_server_open(int fd);
 const char		*rad_server_secret(struct rad_handle *);
 const char		*rad_strerror(struct rad_handle *);
 u_char			*rad_demangle(struct rad_handle *, const void *,

Modified: stable/7/lib/libradius/radlib_private.h
==============================================================================
--- stable/7/lib/libradius/radlib_private.h	Fri Oct 30 12:57:28 2009	(r198672)
+++ stable/7/lib/libradius/radlib_private.h	Fri Oct 30 12:59:22 2009	(r198673)
@@ -38,6 +38,7 @@
 /* Handle types */
 #define RADIUS_AUTH		0   /* RADIUS authentication, default */
 #define RADIUS_ACCT		1   /* RADIUS accounting */
+#define RADIUS_SERVER		2   /* RADIUS server */
 
 /* Defaults */
 #define MAXTRIES		3
@@ -75,18 +76,18 @@ struct rad_handle {
 	int		 num_servers;	/* Number of valid server entries */
 	int		 ident;		/* Current identifier value */
 	char		 errmsg[ERRSIZE];	/* Most recent error message */
-	unsigned char	 request[MSGSIZE];	/* Request to send */
-	char	 	 request_created; /* rad_create_request() called? */
-	int		 req_len;	/* Length of request */
+	unsigned char	 out[MSGSIZE];	/* Request to send */
+	char		 out_created;	/* rad_create_request() called? */
+	int		 out_len;	/* Length of request */
 	char		 pass[PASSSIZE];	/* Cleartext password */
 	int		 pass_len;	/* Length of cleartext password */
 	int		 pass_pos;	/* Position of scrambled password */
-	char	 	 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
+	char		 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
 	int		 authentic_pos;	/* Position of message authenticator */
 	char		 eap_msg;	/* Are we an EAP Proxy? */
-	unsigned char	 response[MSGSIZE];	/* Response received */
-	int		 resp_len;	/* Length of response */
-	int		 resp_pos;	/* Current position scanning attrs */
+	unsigned char	 in[MSGSIZE];	/* Response received */
+	int		 in_len;	/* Length of response */
+	int		 in_pos;	/* Current position scanning attrs */
 	int		 total_tries;	/* How many requests we'll send */
 	int		 try;		/* How many requests we've sent */
 	int		 srv;		/* Server number we did last */

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 13:02:08 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DB3CF106566C;
	Fri, 30 Oct 2009 13:02:08 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C9CFC8FC1E;
	Fri, 30 Oct 2009 13:02:08 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UD28gS045122;
	Fri, 30 Oct 2009 13:02:08 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UD28nq045120;
	Fri, 30 Oct 2009 13:02:08 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910301302.n9UD28nq045120@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 30 Oct 2009 13:02:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198674 - stable/8/lib/libradius
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 13:02:09 -0000

Author: mav
Date: Fri Oct 30 13:02:08 2009
New Revision: 198674
URL: http://svn.freebsd.org/changeset/base/198674

Log:
  MFC rev. 197621:
  Fix bug, when RADIUS client gave up after single sendto() error, do not
  trying backup servers.
  
  PR:		kern/103764, misc/139214

Modified:
  stable/8/lib/libradius/   (props changed)
  stable/8/lib/libradius/radlib.c

Modified: stable/8/lib/libradius/radlib.c
==============================================================================
--- stable/8/lib/libradius/radlib.c	Fri Oct 30 12:59:22 2009	(r198673)
+++ stable/8/lib/libradius/radlib.c	Fri Oct 30 13:02:08 2009	(r198674)
@@ -650,17 +650,12 @@ rad_continue_send_request(struct rad_han
 	n = sendto(h->fd, h->out, h->out_len, 0,
 	    (const struct sockaddr *)&h->servers[h->srv].addr,
 	    sizeof h->servers[h->srv].addr);
-	if (n != h->out_len) {
-		if (n == -1)
-			generr(h, "sendto: %s", strerror(errno));
-		else
-			generr(h, "sendto: short write");
-		return -1;
-	}
-
+	if (n != h->out_len)
+		tv->tv_sec = 1; /* Do not wait full timeout if send failed. */
+	else
+		tv->tv_sec = h->servers[h->srv].timeout;
 	h->try++;
 	h->servers[h->srv].num_tries++;
-	tv->tv_sec = h->servers[h->srv].timeout;
 	tv->tv_usec = 0;
 	*fd = h->fd;
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 13:03:09 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2ED971065670;
	Fri, 30 Oct 2009 13:03:09 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1D9088FC0C;
	Fri, 30 Oct 2009 13:03:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UD39Lm045196;
	Fri, 30 Oct 2009 13:03:09 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UD3880045194;
	Fri, 30 Oct 2009 13:03:08 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910301303.n9UD3880045194@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 30 Oct 2009 13:03:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198675 - stable/7/lib/libradius
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 13:03:09 -0000

Author: mav
Date: Fri Oct 30 13:03:08 2009
New Revision: 198675
URL: http://svn.freebsd.org/changeset/base/198675

Log:
  MFC rev. 197621:
  Fix bug, when RADIUS client gave up after single sendto() error, do not
  trying backup servers.
  
  PR:             kern/103764, misc/139214

Modified:
  stable/7/lib/libradius/   (props changed)
  stable/7/lib/libradius/radlib.c

Modified: stable/7/lib/libradius/radlib.c
==============================================================================
--- stable/7/lib/libradius/radlib.c	Fri Oct 30 13:02:08 2009	(r198674)
+++ stable/7/lib/libradius/radlib.c	Fri Oct 30 13:03:08 2009	(r198675)
@@ -650,17 +650,12 @@ rad_continue_send_request(struct rad_han
 	n = sendto(h->fd, h->out, h->out_len, 0,
 	    (const struct sockaddr *)&h->servers[h->srv].addr,
 	    sizeof h->servers[h->srv].addr);
-	if (n != h->out_len) {
-		if (n == -1)
-			generr(h, "sendto: %s", strerror(errno));
-		else
-			generr(h, "sendto: short write");
-		return -1;
-	}
-
+	if (n != h->out_len)
+		tv->tv_sec = 1; /* Do not wait full timeout if send failed. */
+	else
+		tv->tv_sec = h->servers[h->srv].timeout;
 	h->try++;
 	h->servers[h->srv].num_tries++;
-	tv->tv_sec = h->servers[h->srv].timeout;
 	tv->tv_usec = 0;
 	*fd = h->fd;
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 15:45:00 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B885E1065676;
	Fri, 30 Oct 2009 15:45:00 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A52438FC1F;
	Fri, 30 Oct 2009 15:45:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UFj09i049530;
	Fri, 30 Oct 2009 15:45:00 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UFj0GM049528;
	Fri, 30 Oct 2009 15:45:00 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301545.n9UFj0GM049528@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 15:45:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198676 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci geom/part
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 15:45:00 -0000

Author: rnoland
Date: Fri Oct 30 15:45:00 2009
New Revision: 198676
URL: http://svn.freebsd.org/changeset/base/198676

Log:
  MFC r198097
  
  Set the active flag in the PMBR when we install bootcode on a GPT
  partitioned disk.  Some BIOS require this to be set before they will
  boot the device.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/part/g_part_gpt.c

Modified: stable/8/sys/geom/part/g_part_gpt.c
==============================================================================
--- stable/8/sys/geom/part/g_part_gpt.c	Fri Oct 30 13:03:08 2009	(r198675)
+++ stable/8/sys/geom/part/g_part_gpt.c	Fri Oct 30 15:45:00 2009	(r198676)
@@ -382,6 +382,9 @@ g_part_gpt_bootcode(struct g_part_table 
 	codesz = MIN(codesz, gpp->gpp_codesize);
 	if (codesz > 0)
 		bcopy(gpp->gpp_codeptr, table->mbr, codesz);
+
+	/* Mark the PMBR active since some BIOS require it */
+	table->mbr[DOSPARTOFF] = 0x80;		/* status */
 	return (0);
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 15:45:40 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id ACE6F106568B;
	Fri, 30 Oct 2009 15:45:40 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9B4A48FC21;
	Fri, 30 Oct 2009 15:45:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UFjeVl049585;
	Fri, 30 Oct 2009 15:45:40 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UFjeXD049583;
	Fri, 30 Oct 2009 15:45:40 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301545.n9UFjeXD049583@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 15:45:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198677 - in stable/7/sys: . contrib/pf geom/part
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 15:45:40 -0000

Author: rnoland
Date: Fri Oct 30 15:45:40 2009
New Revision: 198677
URL: http://svn.freebsd.org/changeset/base/198677

Log:
  MFC r198097
  
  Set the active flag in the PMBR when we install bootcode on a GPT
  partitioned disk.  Some BIOS require this to be set before they will
  boot the device.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/geom/part/g_part_gpt.c

Modified: stable/7/sys/geom/part/g_part_gpt.c
==============================================================================
--- stable/7/sys/geom/part/g_part_gpt.c	Fri Oct 30 15:45:00 2009	(r198676)
+++ stable/7/sys/geom/part/g_part_gpt.c	Fri Oct 30 15:45:40 2009	(r198677)
@@ -376,6 +376,9 @@ g_part_gpt_bootcode(struct g_part_table 
 	codesz = MIN(codesz, gpp->gpp_codesize);
 	if (codesz > 0)
 		bcopy(gpp->gpp_codeptr, table->mbr, codesz);
+
+	/* Mark the PMBR active since some BIOS require it */
+	table->mbr[DOSPARTOFF] = 0x80;		/* status */
 	return (0);
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:06:32 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 803A5106568B;
	Fri, 30 Oct 2009 16:06:32 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6D12B8FC0A;
	Fri, 30 Oct 2009 16:06:32 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UG6WTU050260;
	Fri, 30 Oct 2009 16:06:32 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UG6Wvm050258;
	Fri, 30 Oct 2009 16:06:32 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301606.n9UG6Wvm050258@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:06:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198679 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/drm dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:06:32 -0000

Author: rnoland
Date: Fri Oct 30 16:06:32 2009
New Revision: 198679
URL: http://svn.freebsd.org/changeset/base/198679

Log:
  MFC r196464
  
  Clean up the locking in drm_alloc_resource()

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/drm/drm_bufs.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/drm/drm_bufs.c
==============================================================================
--- stable/8/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:00:34 2009	(r198678)
+++ stable/8/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:06:32 2009	(r198679)
@@ -45,27 +45,35 @@ __FBSDID("$FreeBSD$");
  */
 static int drm_alloc_resource(struct drm_device *dev, int resource)
 {
+	struct resource *res;
+	int rid;
+
+	DRM_SPINLOCK_ASSERT(&dev->dev_lock);
+
 	if (resource >= DRM_MAX_PCI_RESOURCE) {
 		DRM_ERROR("Resource %d too large\n", resource);
 		return 1;
 	}
 
-	DRM_UNLOCK();
 	if (dev->pcir[resource] != NULL) {
-		DRM_LOCK();
 		return 0;
 	}
 
-	dev->pcirid[resource] = PCIR_BAR(resource);
-	dev->pcir[resource] = bus_alloc_resource_any(dev->device,
-	    SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE);
+	DRM_UNLOCK();
+	rid = PCIR_BAR(resource);
+	res = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &rid,
+	    RF_SHAREABLE);
 	DRM_LOCK();
-
-	if (dev->pcir[resource] == NULL) {
+	if (res == NULL) {
 		DRM_ERROR("Couldn't find resource 0x%x\n", resource);
 		return 1;
 	}
 
+	if (dev->pcir[resource] == NULL) {
+		dev->pcirid[resource] = rid;
+		dev->pcir[resource] = res;
+	}
+
 	return 0;
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:07:07 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1F178106566C;
	Fri, 30 Oct 2009 16:07:07 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D5948FC0C;
	Fri, 30 Oct 2009 16:07:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UG76QA050312;
	Fri, 30 Oct 2009 16:07:06 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UG76fT050310;
	Fri, 30 Oct 2009 16:07:06 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301607.n9UG76fT050310@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:07:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198680 - in stable/7/sys: . contrib/pf dev/drm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:07:07 -0000

Author: rnoland
Date: Fri Oct 30 16:07:06 2009
New Revision: 198680
URL: http://svn.freebsd.org/changeset/base/198680

Log:
  MFC r196464
  
  Clean up the locking in drm_alloc_resource()

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/drm/drm_bufs.c

Modified: stable/7/sys/dev/drm/drm_bufs.c
==============================================================================
--- stable/7/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:06:32 2009	(r198679)
+++ stable/7/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:07:06 2009	(r198680)
@@ -45,27 +45,35 @@ __FBSDID("$FreeBSD$");
  */
 static int drm_alloc_resource(struct drm_device *dev, int resource)
 {
+	struct resource *res;
+	int rid;
+
+	DRM_SPINLOCK_ASSERT(&dev->dev_lock);
+
 	if (resource >= DRM_MAX_PCI_RESOURCE) {
 		DRM_ERROR("Resource %d too large\n", resource);
 		return 1;
 	}
 
-	DRM_UNLOCK();
 	if (dev->pcir[resource] != NULL) {
-		DRM_LOCK();
 		return 0;
 	}
 
-	dev->pcirid[resource] = PCIR_BAR(resource);
-	dev->pcir[resource] = bus_alloc_resource_any(dev->device,
-	    SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE);
+	DRM_UNLOCK();
+	rid = PCIR_BAR(resource);
+	res = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &rid,
+	    RF_SHAREABLE);
 	DRM_LOCK();
-
-	if (dev->pcir[resource] == NULL) {
+	if (res == NULL) {
 		DRM_ERROR("Couldn't find resource 0x%x\n", resource);
 		return 1;
 	}
 
+	if (dev->pcir[resource] == NULL) {
+		dev->pcirid[resource] = rid;
+		dev->pcir[resource] = res;
+	}
+
 	return 0;
 }
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:12:29 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 648E3106568B;
	Fri, 30 Oct 2009 16:12:29 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5101C8FC15;
	Fri, 30 Oct 2009 16:12:29 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGCT4L050564;
	Fri, 30 Oct 2009 16:12:29 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGCTAS050559;
	Fri, 30 Oct 2009 16:12:29 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301612.n9UGCTAS050559@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:12:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198681 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/drm dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:12:29 -0000

Author: rnoland
Date: Fri Oct 30 16:12:28 2009
New Revision: 198681
URL: http://svn.freebsd.org/changeset/base/198681

Log:
  MFC r196465
  
  Clean up the handling of device minors

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/drm/drmP.h
  stable/8/sys/dev/drm/drm_drv.c
  stable/8/sys/dev/drm/drm_fops.c
  stable/8/sys/dev/drm/drm_sysctl.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/drm/drmP.h
==============================================================================
--- stable/8/sys/dev/drm/drmP.h	Fri Oct 30 16:07:06 2009	(r198680)
+++ stable/8/sys/dev/drm/drmP.h	Fri Oct 30 16:12:28 2009	(r198681)
@@ -416,7 +416,6 @@ struct drm_file {
 	struct drm_device *dev;
 	int		  authenticated;
 	int		  master;
-	int		  minor;
 	pid_t		  pid;
 	uid_t		  uid;
 	drm_magic_t	  magic;

Modified: stable/8/sys/dev/drm/drm_drv.c
==============================================================================
--- stable/8/sys/dev/drm/drm_drv.c	Fri Oct 30 16:07:06 2009	(r198680)
+++ stable/8/sys/dev/drm/drm_drv.c	Fri Oct 30 16:12:28 2009	(r198681)
@@ -53,9 +53,6 @@ static void drm_unload(struct drm_device
 static drm_pci_id_list_t *drm_find_description(int vendor, int device,
     drm_pci_id_list_t *idlist);
 
-#define DRIVER_SOFTC(unit) \
-	((struct drm_device *)devclass_get_softc(drm_devclass, unit))
-
 MODULE_VERSION(drm, 1);
 MODULE_DEPEND(drm, agp, 1, 1, 1);
 MODULE_DEPEND(drm, pci, 1, 1, 1);
@@ -210,11 +207,12 @@ int drm_attach(device_t kdev, drm_pci_id
 	dev->device = kdev;
 #endif
 	dev->devnode = make_dev(&drm_cdevsw,
-			unit,
+			0,
 			DRM_DEV_UID,
 			DRM_DEV_GID,
 			DRM_DEV_MODE,
 			"dri/card%d", unit);
+	dev->devnode->si_drv1 = dev;
 
 #if __FreeBSD_version >= 700053
 	dev->pci_domain = pci_get_domain(dev->device);
@@ -606,7 +604,7 @@ int drm_open(struct cdev *kdev, int flag
 	struct drm_device *dev = NULL;
 	int retcode = 0;
 
-	dev = DRIVER_SOFTC(dev2unit(kdev));
+	dev = kdev->si_drv1;
 
 	DRM_DEBUG("open_count = %d\n", dev->open_count);
 

Modified: stable/8/sys/dev/drm/drm_fops.c
==============================================================================
--- stable/8/sys/dev/drm/drm_fops.c	Fri Oct 30 16:07:06 2009	(r198680)
+++ stable/8/sys/dev/drm/drm_fops.c	Fri Oct 30 16:12:28 2009	(r198681)
@@ -44,14 +44,13 @@ int drm_open_helper(struct cdev *kdev, i
 		    struct drm_device *dev)
 {
 	struct drm_file *priv;
-	int m = dev2unit(kdev);
 	int retcode;
 
 	if (flags & O_EXCL)
 		return EBUSY; /* No exclusive opens */
 	dev->flags = flags;
 
-	DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
+	DRM_DEBUG("pid = %d, device = %s\n", DRM_CURRENTPID, devtoname(kdev));
 
 	priv = malloc(sizeof(*priv), DRM_MEM_FILES, M_NOWAIT | M_ZERO);
 	if (priv == NULL) {
@@ -68,7 +67,6 @@ int drm_open_helper(struct cdev *kdev, i
 	priv->dev		= dev;
 	priv->uid		= p->td_ucred->cr_svuid;
 	priv->pid		= p->td_proc->p_pid;
-	priv->minor		= m;
 	priv->ioctl_count 	= 0;
 
 	/* for compatibility root is always authenticated */

Modified: stable/8/sys/dev/drm/drm_sysctl.c
==============================================================================
--- stable/8/sys/dev/drm/drm_sysctl.c	Fri Oct 30 16:07:06 2009	(r198680)
+++ stable/8/sys/dev/drm/drm_sysctl.c	Fri Oct 30 16:12:28 2009	(r198681)
@@ -298,12 +298,13 @@ static int drm_clients_info DRM_SYSCTL_H
 
 	DRM_UNLOCK();
 
-	DRM_SYSCTL_PRINT("\na dev	pid    uid	magic	  ioctls\n");
+	DRM_SYSCTL_PRINT(
+	    "\na dev            pid   uid      magic     ioctls\n");
 	for (i = 0; i < privcount; i++) {
 		priv = &tempprivs[i];
-		DRM_SYSCTL_PRINT("%c %3d %5d %5d %10u %10lu\n",
+		DRM_SYSCTL_PRINT("%c %-12s %5d %5d %10u %10lu\n",
 			       priv->authenticated ? 'y' : 'n',
-			       priv->minor,
+			       devtoname(priv->dev->devnode),
 			       priv->pid,
 			       priv->uid,
 			       priv->magic,

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:14:17 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F11671065696;
	Fri, 30 Oct 2009 16:14:17 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DDF918FC1A;
	Fri, 30 Oct 2009 16:14:17 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGEH8d050665;
	Fri, 30 Oct 2009 16:14:17 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGEHZL050662;
	Fri, 30 Oct 2009 16:14:17 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301614.n9UGEHZL050662@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:14:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198682 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/drm dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:14:18 -0000

Author: rnoland
Date: Fri Oct 30 16:14:17 2009
New Revision: 198682
URL: http://svn.freebsd.org/changeset/base/198682

Log:
  MFC r196466
  
  Add a read only sysctl tracking the hw.drm.msi tunable.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/drm/drmP.h
  stable/8/sys/dev/drm/drm_drv.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/drm/drmP.h
==============================================================================
--- stable/8/sys/dev/drm/drmP.h	Fri Oct 30 16:12:28 2009	(r198681)
+++ stable/8/sys/dev/drm/drmP.h	Fri Oct 30 16:14:17 2009	(r198682)
@@ -148,6 +148,8 @@ MALLOC_DECLARE(DRM_MEM_CTXBITMAP);
 MALLOC_DECLARE(DRM_MEM_SGLISTS);
 MALLOC_DECLARE(DRM_MEM_DRAWABLE);
 
+SYSCTL_DECL(_hw_drm);
+
 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 
 				/* Internal types and structures */

Modified: stable/8/sys/dev/drm/drm_drv.c
==============================================================================
--- stable/8/sys/dev/drm/drm_drv.c	Fri Oct 30 16:12:28 2009	(r198681)
+++ stable/8/sys/dev/drm/drm_drv.c	Fri Oct 30 16:14:17 2009	(r198682)
@@ -133,6 +133,9 @@ static struct cdevsw drm_cdevsw = {
 
 static int drm_msi = 1;	/* Enable by default. */
 TUNABLE_INT("hw.drm.msi", &drm_msi);
+SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device");
+SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1,
+    "Enable MSI interrupts for drm devices");
 
 static struct drm_msi_blacklist_entry drm_msi_blacklist[] = {
 	{0x8086, 0x2772}, /* Intel i945G	*/ \

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:21:10 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 89F07106566C;
	Fri, 30 Oct 2009 16:21:09 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 77C508FC12;
	Fri, 30 Oct 2009 16:21:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGL95L050862;
	Fri, 30 Oct 2009 16:21:09 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGL9lx050859;
	Fri, 30 Oct 2009 16:21:09 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301621.n9UGL9lx050859@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:21:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198683 - in stable/7/sys: . contrib/pf dev/drm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:21:10 -0000

Author: rnoland
Date: Fri Oct 30 16:21:09 2009
New Revision: 198683
URL: http://svn.freebsd.org/changeset/base/198683

Log:
  MFC r196466
  
  Add a read only sysctl tracking the hw.drm.msi tunable.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/drm/drmP.h
  stable/7/sys/dev/drm/drm_drv.c

Modified: stable/7/sys/dev/drm/drmP.h
==============================================================================
--- stable/7/sys/dev/drm/drmP.h	Fri Oct 30 16:14:17 2009	(r198682)
+++ stable/7/sys/dev/drm/drmP.h	Fri Oct 30 16:21:09 2009	(r198683)
@@ -148,6 +148,8 @@ MALLOC_DECLARE(DRM_MEM_CTXBITMAP);
 MALLOC_DECLARE(DRM_MEM_SGLISTS);
 MALLOC_DECLARE(DRM_MEM_DRAWABLE);
 
+SYSCTL_DECL(_hw_drm);
+
 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 
 				/* Internal types and structures */

Modified: stable/7/sys/dev/drm/drm_drv.c
==============================================================================
--- stable/7/sys/dev/drm/drm_drv.c	Fri Oct 30 16:14:17 2009	(r198682)
+++ stable/7/sys/dev/drm/drm_drv.c	Fri Oct 30 16:21:09 2009	(r198683)
@@ -136,6 +136,9 @@ static struct cdevsw drm_cdevsw = {
 
 static int drm_msi = 1;	/* Enable by default. */
 TUNABLE_INT("hw.drm.msi", &drm_msi);
+SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device");
+SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1,
+    "Enable MSI interrupts for drm devices");
 
 static struct drm_msi_blacklist_entry drm_msi_blacklist[] = {
 	{0x8086, 0x2772}, /* Intel i945G	*/ \

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:32:35 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 93E6E106568D;
	Fri, 30 Oct 2009 16:32:35 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7EE568FC16;
	Fri, 30 Oct 2009 16:32:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGWZPP051233;
	Fri, 30 Oct 2009 16:32:35 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGWZ1h051221;
	Fri, 30 Oct 2009 16:32:35 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301632.n9UGWZ1h051221@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:32:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198685 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris conf contrib/dev/acpica contrib/pf
	dev/drm dev/xen/xenpci modules/drm/radeon
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:32:35 -0000

Author: rnoland
Date: Fri Oct 30 16:32:35 2009
New Revision: 198685
URL: http://svn.freebsd.org/changeset/base/198685

Log:
  MFC r196470-196471,197154-197155,197603-197606
  
  Sync radeon drm support
  
  This adds kernel support for r6/7xx 3D.

Added:
  stable/8/sys/dev/drm/r600_blit.c
     - copied, changed from r196470, head/sys/dev/drm/r600_blit.c
  stable/8/sys/dev/drm/radeon_cs.c
     - copied, changed from r196470, head/sys/dev/drm/radeon_cs.c
Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/conf/files
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/drm/drm_pciids.h
  stable/8/sys/dev/drm/r600_cp.c
  stable/8/sys/dev/drm/radeon_cp.c
  stable/8/sys/dev/drm/radeon_drm.h
  stable/8/sys/dev/drm/radeon_drv.h
  stable/8/sys/dev/drm/radeon_irq.c
  stable/8/sys/dev/drm/radeon_state.c
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/modules/drm/radeon/Makefile

Modified: stable/8/sys/conf/files
==============================================================================
--- stable/8/sys/conf/files	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/conf/files	Fri Oct 30 16:32:35 2009	(r198685)
@@ -845,8 +845,10 @@ dev/drm/r128_irq.c		optional r128drm
 dev/drm/r128_state.c		optional r128drm \
 	compile-with "${NORMAL_C} -finline-limit=13500"
 dev/drm/r300_cmdbuf.c		optional radeondrm
+dev/drm/r600_blit.c		optional radeondrm
 dev/drm/r600_cp.c		optional radeondrm
 dev/drm/radeon_cp.c		optional radeondrm
+dev/drm/radeon_cs.c		optional radeondrm
 dev/drm/radeon_drv.c		optional radeondrm
 dev/drm/radeon_irq.c		optional radeondrm
 dev/drm/radeon_mem.c		optional radeondrm

Modified: stable/8/sys/dev/drm/drm_pciids.h
==============================================================================
--- stable/8/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:32:35 2009	(r198685)
@@ -338,6 +338,7 @@
 	{0x1002, 0x9440, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
 	{0x1002, 0x9441, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4870 X2"}, \
 	{0x1002, 0x9442, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
+	{0x1002, 0x9443, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4850 X2"}, \
 	{0x1002, 0x944C, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
 	{0x1002, 0x9450, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9270"}, \
 	{0x1002, 0x9452, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9250"}, \

Copied and modified: stable/8/sys/dev/drm/r600_blit.c (from r196470, head/sys/dev/drm/r600_blit.c)
==============================================================================
--- head/sys/dev/drm/r600_blit.c	Sun Aug 23 14:55:57 2009	(r196470, copy source)
+++ stable/8/sys/dev/drm/r600_blit.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -1734,6 +1734,8 @@ r600_blit_copy(struct drm_device *dev,
 
 			if (!src_x && !dst_x) {
 				h = (cur_size / max_bytes);
+				if (h > 8192)
+					h = 8192;
 				if (h == 0)
 					h = 1;
 				else
@@ -1805,8 +1807,8 @@ r600_blit_copy(struct drm_device *dev,
 			vb += 12;
 			dev_priv->blit_vb->used += 12 * 4;
 
-			src_gpu_addr += cur_size;
-			dst_gpu_addr += cur_size;
+			src_gpu_addr += cur_size * h;
+			dst_gpu_addr += cur_size * h;
 			size_bytes -= cur_size * h;
 		}
 	} else {
@@ -1822,6 +1824,8 @@ r600_blit_copy(struct drm_device *dev,
 
 			if (!src_x && !dst_x) {
 				h = (cur_size / max_bytes);
+				if (h > 8192)
+					h = 8192;
 				if (h == 0)
 					h = 1;
 				else
@@ -1872,7 +1876,7 @@ r600_blit_copy(struct drm_device *dev,
 
 			/* dst */
 			set_render_target(dev_priv, COLOR_8_8_8_8,
-					  dst_x + cur_size, h,
+					  (dst_x + cur_size) / 4, h,
 					  dst_gpu_addr);
 
 			/* scissors */
@@ -1894,8 +1898,8 @@ r600_blit_copy(struct drm_device *dev,
 			vb += 12;
 			dev_priv->blit_vb->used += 12 * 4;
 
-			src_gpu_addr += cur_size;
-			dst_gpu_addr += cur_size;
+			src_gpu_addr += cur_size * h;
+			dst_gpu_addr += cur_size * h;
 			size_bytes -= cur_size * h;
 		}
 	}

Modified: stable/8/sys/dev/drm/r600_cp.c
==============================================================================
--- stable/8/sys/dev/drm/r600_cp.c	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/r600_cp.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -1843,6 +1843,7 @@ int r600_do_init_cp(struct drm_device *d
 	 */
 	dev_priv->vblank_crtc = DRM_RADEON_VBLANK_CRTC1;
 
+	dev_priv->do_boxes = 0;
 	dev_priv->cp_mode = init->cp_mode;
 
 	/* We don't support anything other than bus-mastering ring mode,
@@ -2100,6 +2101,8 @@ int r600_do_init_cp(struct drm_device *d
 	r600_do_engine_reset(dev);
 	r600_test_writeback(dev_priv);
 
+	r600_cs_init(dev);
+
 	return 0;
 }
 
@@ -2232,3 +2235,135 @@ int r600_cp_dispatch_indirect(struct drm
 
 	return 0;
 }
+
+void r600_cp_dispatch_swap(struct drm_device * dev)
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	int nbox = sarea_priv->nbox;
+	struct drm_clip_rect *pbox = sarea_priv->boxes;
+	int i, cpp, src_pitch, dst_pitch;
+	uint64_t src, dst;
+	RING_LOCALS;
+	DRM_DEBUG("\n");
+
+	if (dev_priv->color_fmt == RADEON_COLOR_FORMAT_ARGB8888)
+		cpp = 4;
+	else
+		cpp = 2;
+
+	if (dev_priv->sarea_priv->pfCurrentPage == 0) {
+		src_pitch = dev_priv->back_pitch;
+		dst_pitch = dev_priv->front_pitch;
+		src = dev_priv->back_offset + dev_priv->fb_location;
+		dst = dev_priv->front_offset + dev_priv->fb_location;
+	} else {
+		src_pitch = dev_priv->front_pitch;
+		dst_pitch = dev_priv->back_pitch;
+		src = dev_priv->front_offset + dev_priv->fb_location;
+		dst = dev_priv->back_offset + dev_priv->fb_location;
+	}
+
+	if (r600_prepare_blit_copy(dev)) {
+		DRM_ERROR("unable to allocate vertex buffer for swap buffer\n");
+		return;
+	}
+	for (i = 0; i < nbox; i++) {
+		int x = pbox[i].x1;
+		int y = pbox[i].y1;
+		int w = pbox[i].x2 - x;
+		int h = pbox[i].y2 - y;
+
+		DRM_DEBUG("%d,%d-%d,%d\n", x, y, w, h);
+
+		r600_blit_swap(dev,
+			       src, dst,
+			       x, y, x, y, w, h,
+			       src_pitch, dst_pitch, cpp);
+	}
+	r600_done_blit_copy(dev);
+
+	/* Increment the frame counter.  The client-side 3D driver must
+	 * throttle the framerate by waiting for this value before
+	 * performing the swapbuffer ioctl.
+	 */
+	dev_priv->sarea_priv->last_frame++;
+
+	BEGIN_RING(3);
+	R600_FRAME_AGE(dev_priv->sarea_priv->last_frame);
+	ADVANCE_RING();
+}
+
+int r600_cp_dispatch_texture(struct drm_device * dev,
+			     struct drm_file *file_priv,
+			     drm_radeon_texture_t * tex,
+			     drm_radeon_tex_image_t * image)
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	struct drm_buf *buf;
+	u32 *buffer;
+	const u8 __user *data;
+	int size, pass_size;
+	u64 src_offset, dst_offset;
+
+	if (!radeon_check_offset(dev_priv, tex->offset)) {
+		DRM_ERROR("Invalid destination offset\n");
+		return -EINVAL;
+	}
+
+	/* this might fail for zero-sized uploads - are those illegal? */
+	if (!radeon_check_offset(dev_priv, tex->offset + tex->height * tex->pitch - 1)) {
+		DRM_ERROR("Invalid final destination offset\n");
+		return -EINVAL;
+	}
+
+	size = tex->height * tex->pitch;
+
+	if (size == 0)
+		return 0;
+
+	dst_offset = tex->offset;
+
+	r600_prepare_blit_copy(dev);
+	do {
+		data = (const u8 __user *)image->data;
+		pass_size = size;
+
+		buf = radeon_freelist_get(dev);
+		if (!buf) {
+			DRM_DEBUG("EAGAIN\n");
+			if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image)))
+				return -EFAULT;
+			return -EAGAIN;
+		}
+
+		if (pass_size > buf->total)
+			pass_size = buf->total;
+
+		/* Dispatch the indirect buffer.
+		 */
+		buffer =
+		    (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset);
+
+		if (DRM_COPY_FROM_USER(buffer, data, pass_size)) {
+			DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size);
+			return -EFAULT;
+		}
+
+		buf->file_priv = file_priv;
+		buf->used = pass_size;
+		src_offset = dev_priv->gart_buffers_offset + buf->offset;
+
+		r600_blit_copy(dev, src_offset, dst_offset, pass_size);
+
+		radeon_cp_discard_buffer(dev, buf);
+
+		/* Update the input parameters for next time */
+		image->data = (const u8 __user *)image->data + pass_size;
+		dst_offset += pass_size;
+		size -= pass_size;
+	} while (size > 0);
+	r600_done_blit_copy(dev);
+
+	return 0;
+}

Modified: stable/8/sys/dev/drm/radeon_cp.c
==============================================================================
--- stable/8/sys/dev/drm/radeon_cp.c	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/radeon_cp.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -408,6 +408,15 @@ static void radeon_init_pipes(drm_radeon
 {
 	uint32_t gb_tile_config, gb_pipe_sel = 0;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) {
+		uint32_t z_pipe_sel = RADEON_READ(RV530_GB_PIPE_SELECT2);
+		if ((z_pipe_sel & 3) == 3)
+			dev_priv->num_z_pipes = 2;
+		else
+			dev_priv->num_z_pipes = 1;
+	} else
+		dev_priv->num_z_pipes = 1;
+
 	/* RS4xx/RS6xx/R4xx/R5xx */
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) {
 		gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT);
@@ -2060,6 +2069,8 @@ int radeon_driver_load(struct drm_device
 	else
 		dev_priv->flags |= RADEON_IS_PCI;
 
+	mtx_init(&dev_priv->cs.cs_mutex, "cs_mtx", NULL, MTX_DEF);
+
 	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
 			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
 			 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
@@ -2112,6 +2123,8 @@ int radeon_driver_unload(struct drm_devi
 
 	drm_rmmap(dev, dev_priv->mmio);
 
+	mtx_destroy(&dev_priv->cs.cs_mutex);
+
 	drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
 
 	dev->dev_private = NULL;
@@ -2126,9 +2139,9 @@ void radeon_commit_ring(drm_radeon_priva
 
 	/* check if the ring is padded out to 16-dword alignment */
 
-	tail_aligned = dev_priv->ring.tail & 0xf;
+	tail_aligned = dev_priv->ring.tail & (RADEON_RING_ALIGN - 1);
 	if (tail_aligned) {
-		int num_p2 = 16 - tail_aligned;
+		int num_p2 = RADEON_RING_ALIGN - tail_aligned;
 
 		ring = dev_priv->ring.start;
 		/* pad with some CP_PACKET2 */

Copied and modified: stable/8/sys/dev/drm/radeon_cs.c (from r196470, head/sys/dev/drm/radeon_cs.c)
==============================================================================
--- head/sys/dev/drm/radeon_cs.c	Sun Aug 23 14:55:57 2009	(r196470, copy source)
+++ stable/8/sys/dev/drm/radeon_cs.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -403,8 +403,8 @@ static inline int r600_cs_packet3(struct
 			DRM_ERROR("bad DRAW_INDEX\n");
 			break;
 		}
-		ib_chunk->kdata[offset_dw + 1] = (offset & 0xffffffff);
-		ib_chunk->kdata[offset_dw + 2] = (upper_32_bits(offset) & 0xff);
+		ib_chunk->kdata[offset_dw + 1] += (offset & 0xffffffff);
+		ib_chunk->kdata[offset_dw + 2] += (upper_32_bits(offset) & 0xff);
 		break;
 	case R600_IT_DRAW_INDEX_AUTO:
 		//DRM_INFO("R600_IT_DRAW_INDEX_AUTO\n");
@@ -433,8 +433,8 @@ static inline int r600_cs_packet3(struct
 				DRM_ERROR("bad WAIT_REG_MEM\n");
 				break;
 			}
-			ib_chunk->kdata[offset_dw + 2] = (offset & 0xffffffff);
-			ib_chunk->kdata[offset_dw + 3] = (upper_32_bits(offset) & 0xff);
+			ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
+			ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		}
 		if (ret)
 			DRM_ERROR("bad WAIT_REG_MEM\n");
@@ -469,7 +469,7 @@ static inline int r600_cs_packet3(struct
 				break;
 			}
 			ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
-			ib_chunk->kdata[offset_dw + 3] |= (upper_32_bits(offset) & 0xff);
+			ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		}
 		if (ret)
 			DRM_ERROR("bad EVENT_WRITE\n");
@@ -488,7 +488,7 @@ static inline int r600_cs_packet3(struct
 			break;
 		}
 		ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
-		ib_chunk->kdata[offset_dw + 3] |= (upper_32_bits(offset) & 0xff);
+		ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		break;
 	case R600_IT_SET_CONFIG_REG:
 		//DRM_INFO("R600_IT_SET_CONFIG_REG\n");
@@ -628,7 +628,7 @@ static inline int r600_cs_packet3(struct
 					if (ret)
 						break;
 					ib_chunk->kdata[offset_dw + (i * 7) + 0 + 2] += (offset & 0xffffffff);
-					ib_chunk->kdata[offset_dw + (i * 7) + 2 + 2] |= (upper_32_bits(offset) & 0xff);
+					ib_chunk->kdata[offset_dw + (i * 7) + 2 + 2] += (upper_32_bits(offset) & 0xff);
 					break;
 				}
 				if (ret)

Modified: stable/8/sys/dev/drm/radeon_drm.h
==============================================================================
--- stable/8/sys/dev/drm/radeon_drm.h	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/radeon_drm.h	Fri Oct 30 16:32:35 2009	(r198685)
@@ -497,6 +497,8 @@ typedef struct {
 #define DRM_RADEON_SURF_ALLOC 0x1a
 #define DRM_RADEON_SURF_FREE  0x1b
 
+#define DRM_RADEON_CS         0x26
+
 #define DRM_IOCTL_RADEON_CP_INIT    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
 #define DRM_IOCTL_RADEON_CP_START   DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_START)
 #define DRM_IOCTL_RADEON_CP_STOP    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t)
@@ -524,6 +526,7 @@ typedef struct {
 #define DRM_IOCTL_RADEON_SETPARAM   DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t)
 #define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t)
 #define DRM_IOCTL_RADEON_SURF_FREE  DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t)
+#define DRM_IOCTL_RADEON_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs)
 
 typedef struct drm_radeon_init {
 	enum {
@@ -685,6 +688,8 @@ typedef struct drm_radeon_indirect {
 #define RADEON_PARAM_VBLANK_CRTC           13   /* VBLANK CRTC */
 #define RADEON_PARAM_FB_LOCATION           14   /* FB location */
 #define RADEON_PARAM_NUM_GB_PIPES          15   /* num GB pipes */
+#define RADEON_PARAM_DEVICE_ID             16
+#define RADEON_PARAM_NUM_Z_PIPES           17   /* num Z pipes */
 
 typedef struct drm_radeon_getparam {
 	int param;
@@ -755,4 +760,23 @@ typedef struct drm_radeon_surface_free {
 #define	DRM_RADEON_VBLANK_CRTC1		1
 #define	DRM_RADEON_VBLANK_CRTC2		2
 
+/* New interface which obsolete all previous interface.
+ */
+#define RADEON_CHUNK_ID_RELOCS 0x01
+#define RADEON_CHUNK_ID_IB     0x02
+#define RADEON_CHUNK_ID_OLD 0xff
+
+struct drm_radeon_cs_chunk {
+	uint32_t chunk_id;
+	uint32_t length_dw;
+	uint64_t chunk_data;
+};
+
+struct drm_radeon_cs {
+	uint32_t        num_chunks;
+	uint32_t        cs_id;
+	uint64_t        chunks; /* this points to uint64_t * which point to
+				   cs chunks */
+};
+
 #endif

Modified: stable/8/sys/dev/drm/radeon_drv.h
==============================================================================
--- stable/8/sys/dev/drm/radeon_drv.h	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/radeon_drv.h	Fri Oct 30 16:32:35 2009	(r198685)
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #define DRIVER_NAME		"radeon"
 #define DRIVER_DESC		"ATI Radeon"
-#define DRIVER_DATE		"20080528"
+#define DRIVER_DATE		"20080613"
 
 /* Interface history:
  *
@@ -102,9 +102,11 @@ __FBSDID("$FreeBSD$");
  * 1.27- Add support for IGP GART
  * 1.28- Add support for VBL on CRTC2
  * 1.29- R500 3D cmd buffer support
+ * 1.30- Add support for occlusion queries
+ * 1.31- Add support for num Z pipes from GET_PARAM
  */
 #define DRIVER_MAJOR		1
-#define DRIVER_MINOR		29
+#define DRIVER_MINOR		31
 #define DRIVER_PATCHLEVEL	0
 
 /*
@@ -141,15 +143,15 @@ enum radeon_family {
 	CHIP_R600,
 	CHIP_RV610,
 	CHIP_RV630,
+	CHIP_RV670,
 	CHIP_RV620,
 	CHIP_RV635,
-	CHIP_RV670,
 	CHIP_RS780,
 	CHIP_RS880,
 	CHIP_RV770,
-	CHIP_RV740,
 	CHIP_RV730,
 	CHIP_RV710,
+	CHIP_RV740,
 	CHIP_LAST,
 };
 
@@ -236,6 +238,46 @@ struct radeon_virt_surface {
 #define PCIGART_FILE_PRIV	((void *) -1L)
 };
 
+struct drm_radeon_kernel_chunk {
+	uint32_t chunk_id;
+	uint32_t length_dw;
+	uint32_t __user *chunk_data;
+	uint32_t *kdata;
+};
+
+struct drm_radeon_cs_parser {
+	struct drm_device *dev;
+	struct drm_file *file_priv;
+	uint32_t num_chunks;
+	struct drm_radeon_kernel_chunk *chunks;
+	int ib_index;
+	int reloc_index;
+	uint32_t card_offset;
+	void *ib;
+};
+
+/* command submission struct */
+struct drm_radeon_cs_priv {
+	struct mtx cs_mutex;
+	uint32_t id_wcnt;
+	uint32_t id_scnt;
+	uint32_t id_last_wcnt;
+	uint32_t id_last_scnt;
+
+	int (*parse)(struct drm_radeon_cs_parser *parser);
+	void (*id_emit)(struct drm_radeon_cs_parser *parser, uint32_t *id);
+	uint32_t (*id_last_get)(struct drm_device *dev);
+	/* this ib handling callback are for hidding memory manager drm
+	 * from memory manager less drm, free have to emit ib discard
+	 * sequence into the ring */
+	int (*ib_get)(struct drm_radeon_cs_parser *parser);
+	uint32_t (*ib_get_ptr)(struct drm_device *dev, void *ib);
+	void (*ib_free)(struct drm_radeon_cs_parser *parser, int error);
+	/* do a relocation either MM or non-MM */
+	int (*relocate)(struct drm_radeon_cs_parser *parser,
+			uint32_t *reloc, uint64_t *offset);
+};
+
 #define RADEON_FLUSH_EMITED	(1 << 0)
 #define RADEON_PURGE_EMITED	(1 << 1)
 
@@ -328,6 +370,7 @@ typedef struct drm_radeon_private {
 	unsigned long fb_aper_offset;
 
 	int num_gb_pipes;
+	int num_z_pipes;
 	int track_flush;
 	drm_local_map_t *mmio;
 
@@ -349,6 +392,12 @@ typedef struct drm_radeon_private {
 	int r700_sc_prim_fifo_size;
 	int r700_sc_hiz_tile_fifo_size;
 	int r700_sc_earlyz_tile_fifo_fize;
+	/* r6xx/r7xx drm blit vertex buffer */
+	struct drm_buf *blit_vb;
+
+	/* CS */
+	struct drm_radeon_cs_priv cs;
+	struct drm_buf *cs_buf;
 
 } drm_radeon_private_t;
 
@@ -379,10 +428,10 @@ extern void radeon_set_ring_head(drm_rad
 static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
 					  u64 off)
 {
-	u32 fb_start = dev_priv->fb_location;
-	u32 fb_end = fb_start + dev_priv->fb_size - 1;
-	u32 gart_start = dev_priv->gart_vm_start;
-	u32 gart_end = gart_start + dev_priv->gart_size - 1;
+	u64 fb_start = dev_priv->fb_location;
+	u64 fb_end = fb_start + dev_priv->fb_size - 1;
+	u64 gart_start = dev_priv->gart_vm_start;
+	u64 gart_end = gart_start + dev_priv->gart_size - 1;
 
 	return ((off >= fb_start && off <= fb_end) ||
 		(off >= gart_start && off <= gart_end));
@@ -476,6 +525,33 @@ extern int r600_cp_dispatch_indirect(str
 				     struct drm_buf *buf, int start, int end);
 extern int r600_page_table_init(struct drm_device *dev);
 extern void r600_page_table_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
+extern void r600_cp_dispatch_swap(struct drm_device * dev);
+extern int r600_cp_dispatch_texture(struct drm_device * dev,
+				    struct drm_file *file_priv,
+				    drm_radeon_texture_t * tex,
+				    drm_radeon_tex_image_t * image);
+
+/* r600_blit.c */
+extern int
+r600_prepare_blit_copy(struct drm_device *dev);
+extern void
+r600_done_blit_copy(struct drm_device *dev);
+extern void
+r600_blit_copy(struct drm_device *dev,
+	       uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
+	       int size_bytes);
+extern void
+r600_blit_swap(struct drm_device *dev,
+	       uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
+	       int sx, int sy, int dx, int dy,
+	       int w, int h, int src_pitch, int dst_pitch, int cpp);
+
+/* radeon_state.c */
+extern void radeon_cp_discard_buffer(struct drm_device * dev, struct drm_buf * buf);
+
+/* radeon_cs.c */
+extern int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *fpriv);
+extern int r600_cs_init(struct drm_device *dev);
 
 /* Flags for stats.boxes
  */
@@ -685,6 +761,7 @@ extern void r600_page_table_cleanup(stru
 
 /* pipe config regs */
 #define R400_GB_PIPE_SELECT             0x402c
+#define RV530_GB_PIPE_SELECT2           0x4124
 #define R500_DYN_SCLK_PWMEM_PIPE        0x000d /* PLL */
 #define R300_GB_TILE_CONFIG             0x4018
 #       define R300_ENABLE_TILING       (1 << 0)
@@ -1827,26 +1904,38 @@ do {									\
  */
 
 #define RADEON_WAIT_UNTIL_2D_IDLE() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_3D_IDLE() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_3D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_IDLE() do {					\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
 		   RADEON_WAIT_3D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( RADEON_WAIT_CRTC_PFLIP );				\
 } while (0)
 
@@ -1961,14 +2050,17 @@ do {								\
 
 #define RING_LOCALS	int write, _nr, _align_nr; unsigned int mask; u32 *ring;
 
+#define RADEON_RING_ALIGN 16
+
 #define BEGIN_RING( n ) do {						\
 	if ( RADEON_VERBOSE ) {						\
 		DRM_INFO( "BEGIN_RING( %d )\n", (n));			\
 	}								\
-	_align_nr = (n + 0xf) & ~0xf;					\
-	if (dev_priv->ring.space <= (_align_nr * sizeof(u32))) {	\
-                COMMIT_RING();						\
-		radeon_wait_ring( dev_priv, _align_nr * sizeof(u32));	\
+	_align_nr = RADEON_RING_ALIGN - ((dev_priv->ring.tail + n) & (RADEON_RING_ALIGN - 1)); \
+	_align_nr += n;							\
+	if ( dev_priv->ring.space <= (_align_nr) * sizeof(u32) ) {	\
+		COMMIT_RING();						\
+		radeon_wait_ring( dev_priv, (_align_nr) * sizeof(u32) ); \
 	}								\
 	_nr = n; dev_priv->ring.space -= (n) * sizeof(u32);		\
 	ring = dev_priv->ring.start;					\

Modified: stable/8/sys/dev/drm/radeon_irq.c
==============================================================================
--- stable/8/sys/dev/drm/radeon_irq.c	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/radeon_irq.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -194,6 +194,9 @@ irqreturn_t radeon_driver_irq_handler(DR
 	u32 r500_disp_int;
 	u32 tmp;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return IRQ_NONE;
+
 	/* Only consider the bits we're interested in - others could be used
 	 * outside the DRM
 	 */
@@ -323,6 +326,9 @@ int radeon_irq_emit(struct drm_device *d
 	drm_radeon_irq_emit_t *emit = data;
 	int result;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return -EINVAL;
+
 	LOCK_TEST_WITH_RETURN(dev, file_priv);
 
 	if (!dev_priv) {
@@ -363,6 +369,9 @@ void radeon_driver_irq_preinstall(struct
 	    (drm_radeon_private_t *) dev->dev_private;
 	u32 dummy;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return;
+
 	/* Disable *all* interrupts */
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
 		RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
@@ -380,6 +389,9 @@ int radeon_driver_irq_postinstall(struct
 	atomic_set(&dev_priv->swi_emitted, 0);
 	DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return 0;
+
 	radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1);
 
 	return 0;
@@ -394,6 +406,9 @@ void radeon_driver_irq_uninstall(struct 
 
 	dev_priv->irq_enabled = 0;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return;
+
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
 		RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
 	/* Disable *all* interrupts */

Modified: stable/8/sys/dev/drm/radeon_state.c
==============================================================================
--- stable/8/sys/dev/drm/radeon_state.c	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/dev/drm/radeon_state.c	Fri Oct 30 16:32:35 2009	(r198685)
@@ -1541,7 +1541,7 @@ static void radeon_cp_dispatch_vertex(st
 	} while (i < nbox);
 }
 
-static void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_buf *buf)
+void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_buf *buf)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
@@ -2202,7 +2202,10 @@ static int radeon_cp_swap(struct drm_dev
 	if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
 		sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
 
-	radeon_cp_dispatch_swap(dev);
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		r600_cp_dispatch_swap(dev);
+	else
+		radeon_cp_dispatch_swap(dev);
 	sarea_priv->ctx_owner = 0;
 
 	COMMIT_RING();
@@ -2399,7 +2402,10 @@ static int radeon_cp_texture(struct drm_
 	RING_SPACE_TEST_WITH_RETURN(dev_priv);
 	VB_AGE_TEST_WITH_RETURN(dev_priv);
 
-	ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image);
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		ret = r600_cp_dispatch_texture(dev, file_priv, tex, &image);
+	else
+		ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image);
 
 	return ret;
 }
@@ -3018,7 +3024,10 @@ static int radeon_cp_getparam(struct drm
 		value = GET_SCRATCH(dev_priv, 2);
 		break;
 	case RADEON_PARAM_IRQ_NR:
-		value = dev->irq;
+		if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+			value = 0;
+		else
+			value = dev->irq;
 		break;
 	case RADEON_PARAM_GART_BASE:
 		value = dev_priv->gart_vm_start;
@@ -3072,6 +3081,9 @@ static int radeon_cp_getparam(struct drm
 	case RADEON_PARAM_NUM_GB_PIPES:
 		value = dev_priv->num_gb_pipes;
 		break;
+	case RADEON_PARAM_NUM_Z_PIPES:
+		value = dev_priv->num_z_pipes;
+		break;
 	default:
 		DRM_DEBUG("Invalid parameter %d\n", param->param);
 		return -EINVAL;
@@ -3156,6 +3168,14 @@ void radeon_driver_preclose(struct drm_d
 void radeon_driver_lastclose(struct drm_device *dev)
 {
 	radeon_surfaces_release(PCIGART_FILE_PRIV, dev->dev_private);
+	if (dev->dev_private) {
+		drm_radeon_private_t *dev_priv = dev->dev_private;
+
+		if (dev_priv->sarea_priv &&
+		    dev_priv->sarea_priv->pfCurrentPage != 0)
+			radeon_cp_dispatch_flip(dev);
+	}
+
 	radeon_do_release(dev);
 }
 
@@ -3216,7 +3236,8 @@ struct drm_ioctl_desc radeon_ioctls[] = 
 	DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH)
+	DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_RADEON_CS, radeon_cs_ioctl, DRM_AUTH)
 };
 
 int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls);

Modified: stable/8/sys/modules/drm/radeon/Makefile
==============================================================================
--- stable/8/sys/modules/drm/radeon/Makefile	Fri Oct 30 16:23:56 2009	(r198684)
+++ stable/8/sys/modules/drm/radeon/Makefile	Fri Oct 30 16:32:35 2009	(r198685)
@@ -2,8 +2,8 @@
 
 .PATH:	${.CURDIR}/../../../dev/drm
 KMOD	= radeon
-SRCS	= r300_cmdbuf.c r600_cp.c radeon_cp.c radeon_drv.c radeon_irq.c \
-	radeon_mem.c radeon_state.c
+SRCS	= r300_cmdbuf.c r600_blit.c r600_cp.c radeon_cp.c radeon_cs.c \
+	radeon_drv.c radeon_irq.c radeon_mem.c radeon_state.c
 SRCS	+=device_if.h bus_if.h pci_if.h opt_drm.h
 
 .include 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:35:48 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 153781065679;
	Fri, 30 Oct 2009 16:35:48 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 017328FC15;
	Fri, 30 Oct 2009 16:35:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGZlGm051380;
	Fri, 30 Oct 2009 16:35:47 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGZlB7051367;
	Fri, 30 Oct 2009 16:35:47 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301635.n9UGZlB7051367@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:35:47 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198686 - in stable/7/sys: . conf contrib/pf dev/drm
	modules/drm/radeon
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:35:48 -0000

Author: rnoland
Date: Fri Oct 30 16:35:47 2009
New Revision: 198686
URL: http://svn.freebsd.org/changeset/base/198686

Log:
  MFC r196470-196471,197154-197155,197603-197606
  
  Sync radeon drm support
  
  This adds kernel support for r6/7xx 3D.

Added:
  stable/7/sys/dev/drm/r600_blit.c
     - copied, changed from r196470, head/sys/dev/drm/r600_blit.c
  stable/7/sys/dev/drm/radeon_cs.c
     - copied, changed from r196470, head/sys/dev/drm/radeon_cs.c
Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/conf/files
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/drm/drm_pciids.h
  stable/7/sys/dev/drm/r600_cp.c
  stable/7/sys/dev/drm/radeon_cp.c
  stable/7/sys/dev/drm/radeon_drm.h
  stable/7/sys/dev/drm/radeon_drv.h
  stable/7/sys/dev/drm/radeon_irq.c
  stable/7/sys/dev/drm/radeon_state.c
  stable/7/sys/modules/drm/radeon/Makefile

Modified: stable/7/sys/conf/files
==============================================================================
--- stable/7/sys/conf/files	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/conf/files	Fri Oct 30 16:35:47 2009	(r198686)
@@ -757,8 +757,10 @@ dev/drm/r128_irq.c		optional r128drm
 dev/drm/r128_state.c		optional r128drm \
 	compile-with "${NORMAL_C} -finline-limit=13500"
 dev/drm/r300_cmdbuf.c		optional radeondrm
+dev/drm/r600_blit.c		optional radeondrm
 dev/drm/r600_cp.c		optional radeondrm
 dev/drm/radeon_cp.c		optional radeondrm
+dev/drm/radeon_cs.c		optional radeondrm
 dev/drm/radeon_drv.c		optional radeondrm
 dev/drm/radeon_irq.c		optional radeondrm
 dev/drm/radeon_mem.c		optional radeondrm

Modified: stable/7/sys/dev/drm/drm_pciids.h
==============================================================================
--- stable/7/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:35:47 2009	(r198686)
@@ -338,6 +338,7 @@
 	{0x1002, 0x9440, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
 	{0x1002, 0x9441, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4870 X2"}, \
 	{0x1002, 0x9442, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
+	{0x1002, 0x9443, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4850 X2"}, \
 	{0x1002, 0x944C, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \
 	{0x1002, 0x9450, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9270"}, \
 	{0x1002, 0x9452, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9250"}, \

Copied and modified: stable/7/sys/dev/drm/r600_blit.c (from r196470, head/sys/dev/drm/r600_blit.c)
==============================================================================
--- head/sys/dev/drm/r600_blit.c	Sun Aug 23 14:55:57 2009	(r196470, copy source)
+++ stable/7/sys/dev/drm/r600_blit.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -1734,6 +1734,8 @@ r600_blit_copy(struct drm_device *dev,
 
 			if (!src_x && !dst_x) {
 				h = (cur_size / max_bytes);
+				if (h > 8192)
+					h = 8192;
 				if (h == 0)
 					h = 1;
 				else
@@ -1805,8 +1807,8 @@ r600_blit_copy(struct drm_device *dev,
 			vb += 12;
 			dev_priv->blit_vb->used += 12 * 4;
 
-			src_gpu_addr += cur_size;
-			dst_gpu_addr += cur_size;
+			src_gpu_addr += cur_size * h;
+			dst_gpu_addr += cur_size * h;
 			size_bytes -= cur_size * h;
 		}
 	} else {
@@ -1822,6 +1824,8 @@ r600_blit_copy(struct drm_device *dev,
 
 			if (!src_x && !dst_x) {
 				h = (cur_size / max_bytes);
+				if (h > 8192)
+					h = 8192;
 				if (h == 0)
 					h = 1;
 				else
@@ -1872,7 +1876,7 @@ r600_blit_copy(struct drm_device *dev,
 
 			/* dst */
 			set_render_target(dev_priv, COLOR_8_8_8_8,
-					  dst_x + cur_size, h,
+					  (dst_x + cur_size) / 4, h,
 					  dst_gpu_addr);
 
 			/* scissors */
@@ -1894,8 +1898,8 @@ r600_blit_copy(struct drm_device *dev,
 			vb += 12;
 			dev_priv->blit_vb->used += 12 * 4;
 
-			src_gpu_addr += cur_size;
-			dst_gpu_addr += cur_size;
+			src_gpu_addr += cur_size * h;
+			dst_gpu_addr += cur_size * h;
 			size_bytes -= cur_size * h;
 		}
 	}

Modified: stable/7/sys/dev/drm/r600_cp.c
==============================================================================
--- stable/7/sys/dev/drm/r600_cp.c	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/r600_cp.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -1843,6 +1843,7 @@ int r600_do_init_cp(struct drm_device *d
 	 */
 	dev_priv->vblank_crtc = DRM_RADEON_VBLANK_CRTC1;
 
+	dev_priv->do_boxes = 0;
 	dev_priv->cp_mode = init->cp_mode;
 
 	/* We don't support anything other than bus-mastering ring mode,
@@ -2100,6 +2101,8 @@ int r600_do_init_cp(struct drm_device *d
 	r600_do_engine_reset(dev);
 	r600_test_writeback(dev_priv);
 
+	r600_cs_init(dev);
+
 	return 0;
 }
 
@@ -2232,3 +2235,135 @@ int r600_cp_dispatch_indirect(struct drm
 
 	return 0;
 }
+
+void r600_cp_dispatch_swap(struct drm_device * dev)
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	int nbox = sarea_priv->nbox;
+	struct drm_clip_rect *pbox = sarea_priv->boxes;
+	int i, cpp, src_pitch, dst_pitch;
+	uint64_t src, dst;
+	RING_LOCALS;
+	DRM_DEBUG("\n");
+
+	if (dev_priv->color_fmt == RADEON_COLOR_FORMAT_ARGB8888)
+		cpp = 4;
+	else
+		cpp = 2;
+
+	if (dev_priv->sarea_priv->pfCurrentPage == 0) {
+		src_pitch = dev_priv->back_pitch;
+		dst_pitch = dev_priv->front_pitch;
+		src = dev_priv->back_offset + dev_priv->fb_location;
+		dst = dev_priv->front_offset + dev_priv->fb_location;
+	} else {
+		src_pitch = dev_priv->front_pitch;
+		dst_pitch = dev_priv->back_pitch;
+		src = dev_priv->front_offset + dev_priv->fb_location;
+		dst = dev_priv->back_offset + dev_priv->fb_location;
+	}
+
+	if (r600_prepare_blit_copy(dev)) {
+		DRM_ERROR("unable to allocate vertex buffer for swap buffer\n");
+		return;
+	}
+	for (i = 0; i < nbox; i++) {
+		int x = pbox[i].x1;
+		int y = pbox[i].y1;
+		int w = pbox[i].x2 - x;
+		int h = pbox[i].y2 - y;
+
+		DRM_DEBUG("%d,%d-%d,%d\n", x, y, w, h);
+
+		r600_blit_swap(dev,
+			       src, dst,
+			       x, y, x, y, w, h,
+			       src_pitch, dst_pitch, cpp);
+	}
+	r600_done_blit_copy(dev);
+
+	/* Increment the frame counter.  The client-side 3D driver must
+	 * throttle the framerate by waiting for this value before
+	 * performing the swapbuffer ioctl.
+	 */
+	dev_priv->sarea_priv->last_frame++;
+
+	BEGIN_RING(3);
+	R600_FRAME_AGE(dev_priv->sarea_priv->last_frame);
+	ADVANCE_RING();
+}
+
+int r600_cp_dispatch_texture(struct drm_device * dev,
+			     struct drm_file *file_priv,
+			     drm_radeon_texture_t * tex,
+			     drm_radeon_tex_image_t * image)
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	struct drm_buf *buf;
+	u32 *buffer;
+	const u8 __user *data;
+	int size, pass_size;
+	u64 src_offset, dst_offset;
+
+	if (!radeon_check_offset(dev_priv, tex->offset)) {
+		DRM_ERROR("Invalid destination offset\n");
+		return -EINVAL;
+	}
+
+	/* this might fail for zero-sized uploads - are those illegal? */
+	if (!radeon_check_offset(dev_priv, tex->offset + tex->height * tex->pitch - 1)) {
+		DRM_ERROR("Invalid final destination offset\n");
+		return -EINVAL;
+	}
+
+	size = tex->height * tex->pitch;
+
+	if (size == 0)
+		return 0;
+
+	dst_offset = tex->offset;
+
+	r600_prepare_blit_copy(dev);
+	do {
+		data = (const u8 __user *)image->data;
+		pass_size = size;
+
+		buf = radeon_freelist_get(dev);
+		if (!buf) {
+			DRM_DEBUG("EAGAIN\n");
+			if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image)))
+				return -EFAULT;
+			return -EAGAIN;
+		}
+
+		if (pass_size > buf->total)
+			pass_size = buf->total;
+
+		/* Dispatch the indirect buffer.
+		 */
+		buffer =
+		    (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset);
+
+		if (DRM_COPY_FROM_USER(buffer, data, pass_size)) {
+			DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size);
+			return -EFAULT;
+		}
+
+		buf->file_priv = file_priv;
+		buf->used = pass_size;
+		src_offset = dev_priv->gart_buffers_offset + buf->offset;
+
+		r600_blit_copy(dev, src_offset, dst_offset, pass_size);
+
+		radeon_cp_discard_buffer(dev, buf);
+
+		/* Update the input parameters for next time */
+		image->data = (const u8 __user *)image->data + pass_size;
+		dst_offset += pass_size;
+		size -= pass_size;
+	} while (size > 0);
+	r600_done_blit_copy(dev);
+
+	return 0;
+}

Modified: stable/7/sys/dev/drm/radeon_cp.c
==============================================================================
--- stable/7/sys/dev/drm/radeon_cp.c	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/radeon_cp.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -408,6 +408,15 @@ static void radeon_init_pipes(drm_radeon
 {
 	uint32_t gb_tile_config, gb_pipe_sel = 0;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) {
+		uint32_t z_pipe_sel = RADEON_READ(RV530_GB_PIPE_SELECT2);
+		if ((z_pipe_sel & 3) == 3)
+			dev_priv->num_z_pipes = 2;
+		else
+			dev_priv->num_z_pipes = 1;
+	} else
+		dev_priv->num_z_pipes = 1;
+
 	/* RS4xx/RS6xx/R4xx/R5xx */
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) {
 		gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT);
@@ -2060,6 +2069,8 @@ int radeon_driver_load(struct drm_device
 	else
 		dev_priv->flags |= RADEON_IS_PCI;
 
+	mtx_init(&dev_priv->cs.cs_mutex, "cs_mtx", NULL, MTX_DEF);
+
 	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
 			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
 			 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
@@ -2112,6 +2123,8 @@ int radeon_driver_unload(struct drm_devi
 
 	drm_rmmap(dev, dev_priv->mmio);
 
+	mtx_destroy(&dev_priv->cs.cs_mutex);
+
 	drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
 
 	dev->dev_private = NULL;
@@ -2126,9 +2139,9 @@ void radeon_commit_ring(drm_radeon_priva
 
 	/* check if the ring is padded out to 16-dword alignment */
 
-	tail_aligned = dev_priv->ring.tail & 0xf;
+	tail_aligned = dev_priv->ring.tail & (RADEON_RING_ALIGN - 1);
 	if (tail_aligned) {
-		int num_p2 = 16 - tail_aligned;
+		int num_p2 = RADEON_RING_ALIGN - tail_aligned;
 
 		ring = dev_priv->ring.start;
 		/* pad with some CP_PACKET2 */

Copied and modified: stable/7/sys/dev/drm/radeon_cs.c (from r196470, head/sys/dev/drm/radeon_cs.c)
==============================================================================
--- head/sys/dev/drm/radeon_cs.c	Sun Aug 23 14:55:57 2009	(r196470, copy source)
+++ stable/7/sys/dev/drm/radeon_cs.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -403,8 +403,8 @@ static inline int r600_cs_packet3(struct
 			DRM_ERROR("bad DRAW_INDEX\n");
 			break;
 		}
-		ib_chunk->kdata[offset_dw + 1] = (offset & 0xffffffff);
-		ib_chunk->kdata[offset_dw + 2] = (upper_32_bits(offset) & 0xff);
+		ib_chunk->kdata[offset_dw + 1] += (offset & 0xffffffff);
+		ib_chunk->kdata[offset_dw + 2] += (upper_32_bits(offset) & 0xff);
 		break;
 	case R600_IT_DRAW_INDEX_AUTO:
 		//DRM_INFO("R600_IT_DRAW_INDEX_AUTO\n");
@@ -433,8 +433,8 @@ static inline int r600_cs_packet3(struct
 				DRM_ERROR("bad WAIT_REG_MEM\n");
 				break;
 			}
-			ib_chunk->kdata[offset_dw + 2] = (offset & 0xffffffff);
-			ib_chunk->kdata[offset_dw + 3] = (upper_32_bits(offset) & 0xff);
+			ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
+			ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		}
 		if (ret)
 			DRM_ERROR("bad WAIT_REG_MEM\n");
@@ -469,7 +469,7 @@ static inline int r600_cs_packet3(struct
 				break;
 			}
 			ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
-			ib_chunk->kdata[offset_dw + 3] |= (upper_32_bits(offset) & 0xff);
+			ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		}
 		if (ret)
 			DRM_ERROR("bad EVENT_WRITE\n");
@@ -488,7 +488,7 @@ static inline int r600_cs_packet3(struct
 			break;
 		}
 		ib_chunk->kdata[offset_dw + 2] += (offset & 0xffffffff);
-		ib_chunk->kdata[offset_dw + 3] |= (upper_32_bits(offset) & 0xff);
+		ib_chunk->kdata[offset_dw + 3] += (upper_32_bits(offset) & 0xff);
 		break;
 	case R600_IT_SET_CONFIG_REG:
 		//DRM_INFO("R600_IT_SET_CONFIG_REG\n");
@@ -628,7 +628,7 @@ static inline int r600_cs_packet3(struct
 					if (ret)
 						break;
 					ib_chunk->kdata[offset_dw + (i * 7) + 0 + 2] += (offset & 0xffffffff);
-					ib_chunk->kdata[offset_dw + (i * 7) + 2 + 2] |= (upper_32_bits(offset) & 0xff);
+					ib_chunk->kdata[offset_dw + (i * 7) + 2 + 2] += (upper_32_bits(offset) & 0xff);
 					break;
 				}
 				if (ret)

Modified: stable/7/sys/dev/drm/radeon_drm.h
==============================================================================
--- stable/7/sys/dev/drm/radeon_drm.h	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/radeon_drm.h	Fri Oct 30 16:35:47 2009	(r198686)
@@ -497,6 +497,8 @@ typedef struct {
 #define DRM_RADEON_SURF_ALLOC 0x1a
 #define DRM_RADEON_SURF_FREE  0x1b
 
+#define DRM_RADEON_CS         0x26
+
 #define DRM_IOCTL_RADEON_CP_INIT    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
 #define DRM_IOCTL_RADEON_CP_START   DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_START)
 #define DRM_IOCTL_RADEON_CP_STOP    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t)
@@ -524,6 +526,7 @@ typedef struct {
 #define DRM_IOCTL_RADEON_SETPARAM   DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t)
 #define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t)
 #define DRM_IOCTL_RADEON_SURF_FREE  DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t)
+#define DRM_IOCTL_RADEON_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs)
 
 typedef struct drm_radeon_init {
 	enum {
@@ -685,6 +688,8 @@ typedef struct drm_radeon_indirect {
 #define RADEON_PARAM_VBLANK_CRTC           13   /* VBLANK CRTC */
 #define RADEON_PARAM_FB_LOCATION           14   /* FB location */
 #define RADEON_PARAM_NUM_GB_PIPES          15   /* num GB pipes */
+#define RADEON_PARAM_DEVICE_ID             16
+#define RADEON_PARAM_NUM_Z_PIPES           17   /* num Z pipes */
 
 typedef struct drm_radeon_getparam {
 	int param;
@@ -755,4 +760,23 @@ typedef struct drm_radeon_surface_free {
 #define	DRM_RADEON_VBLANK_CRTC1		1
 #define	DRM_RADEON_VBLANK_CRTC2		2
 
+/* New interface which obsolete all previous interface.
+ */
+#define RADEON_CHUNK_ID_RELOCS 0x01
+#define RADEON_CHUNK_ID_IB     0x02
+#define RADEON_CHUNK_ID_OLD 0xff
+
+struct drm_radeon_cs_chunk {
+	uint32_t chunk_id;
+	uint32_t length_dw;
+	uint64_t chunk_data;
+};
+
+struct drm_radeon_cs {
+	uint32_t        num_chunks;
+	uint32_t        cs_id;
+	uint64_t        chunks; /* this points to uint64_t * which point to
+				   cs chunks */
+};
+
 #endif

Modified: stable/7/sys/dev/drm/radeon_drv.h
==============================================================================
--- stable/7/sys/dev/drm/radeon_drv.h	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/radeon_drv.h	Fri Oct 30 16:35:47 2009	(r198686)
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #define DRIVER_NAME		"radeon"
 #define DRIVER_DESC		"ATI Radeon"
-#define DRIVER_DATE		"20080528"
+#define DRIVER_DATE		"20080613"
 
 /* Interface history:
  *
@@ -102,9 +102,11 @@ __FBSDID("$FreeBSD$");
  * 1.27- Add support for IGP GART
  * 1.28- Add support for VBL on CRTC2
  * 1.29- R500 3D cmd buffer support
+ * 1.30- Add support for occlusion queries
+ * 1.31- Add support for num Z pipes from GET_PARAM
  */
 #define DRIVER_MAJOR		1
-#define DRIVER_MINOR		29
+#define DRIVER_MINOR		31
 #define DRIVER_PATCHLEVEL	0
 
 /*
@@ -141,15 +143,15 @@ enum radeon_family {
 	CHIP_R600,
 	CHIP_RV610,
 	CHIP_RV630,
+	CHIP_RV670,
 	CHIP_RV620,
 	CHIP_RV635,
-	CHIP_RV670,
 	CHIP_RS780,
 	CHIP_RS880,
 	CHIP_RV770,
-	CHIP_RV740,
 	CHIP_RV730,
 	CHIP_RV710,
+	CHIP_RV740,
 	CHIP_LAST,
 };
 
@@ -236,6 +238,46 @@ struct radeon_virt_surface {
 #define PCIGART_FILE_PRIV	((void *) -1L)
 };
 
+struct drm_radeon_kernel_chunk {
+	uint32_t chunk_id;
+	uint32_t length_dw;
+	uint32_t __user *chunk_data;
+	uint32_t *kdata;
+};
+
+struct drm_radeon_cs_parser {
+	struct drm_device *dev;
+	struct drm_file *file_priv;
+	uint32_t num_chunks;
+	struct drm_radeon_kernel_chunk *chunks;
+	int ib_index;
+	int reloc_index;
+	uint32_t card_offset;
+	void *ib;
+};
+
+/* command submission struct */
+struct drm_radeon_cs_priv {
+	struct mtx cs_mutex;
+	uint32_t id_wcnt;
+	uint32_t id_scnt;
+	uint32_t id_last_wcnt;
+	uint32_t id_last_scnt;
+
+	int (*parse)(struct drm_radeon_cs_parser *parser);
+	void (*id_emit)(struct drm_radeon_cs_parser *parser, uint32_t *id);
+	uint32_t (*id_last_get)(struct drm_device *dev);
+	/* this ib handling callback are for hidding memory manager drm
+	 * from memory manager less drm, free have to emit ib discard
+	 * sequence into the ring */
+	int (*ib_get)(struct drm_radeon_cs_parser *parser);
+	uint32_t (*ib_get_ptr)(struct drm_device *dev, void *ib);
+	void (*ib_free)(struct drm_radeon_cs_parser *parser, int error);
+	/* do a relocation either MM or non-MM */
+	int (*relocate)(struct drm_radeon_cs_parser *parser,
+			uint32_t *reloc, uint64_t *offset);
+};
+
 #define RADEON_FLUSH_EMITED	(1 << 0)
 #define RADEON_PURGE_EMITED	(1 << 1)
 
@@ -328,6 +370,7 @@ typedef struct drm_radeon_private {
 	unsigned long fb_aper_offset;
 
 	int num_gb_pipes;
+	int num_z_pipes;
 	int track_flush;
 	drm_local_map_t *mmio;
 
@@ -349,6 +392,12 @@ typedef struct drm_radeon_private {
 	int r700_sc_prim_fifo_size;
 	int r700_sc_hiz_tile_fifo_size;
 	int r700_sc_earlyz_tile_fifo_fize;
+	/* r6xx/r7xx drm blit vertex buffer */
+	struct drm_buf *blit_vb;
+
+	/* CS */
+	struct drm_radeon_cs_priv cs;
+	struct drm_buf *cs_buf;
 
 } drm_radeon_private_t;
 
@@ -379,10 +428,10 @@ extern void radeon_set_ring_head(drm_rad
 static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
 					  u64 off)
 {
-	u32 fb_start = dev_priv->fb_location;
-	u32 fb_end = fb_start + dev_priv->fb_size - 1;
-	u32 gart_start = dev_priv->gart_vm_start;
-	u32 gart_end = gart_start + dev_priv->gart_size - 1;
+	u64 fb_start = dev_priv->fb_location;
+	u64 fb_end = fb_start + dev_priv->fb_size - 1;
+	u64 gart_start = dev_priv->gart_vm_start;
+	u64 gart_end = gart_start + dev_priv->gart_size - 1;
 
 	return ((off >= fb_start && off <= fb_end) ||
 		(off >= gart_start && off <= gart_end));
@@ -476,6 +525,33 @@ extern int r600_cp_dispatch_indirect(str
 				     struct drm_buf *buf, int start, int end);
 extern int r600_page_table_init(struct drm_device *dev);
 extern void r600_page_table_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
+extern void r600_cp_dispatch_swap(struct drm_device * dev);
+extern int r600_cp_dispatch_texture(struct drm_device * dev,
+				    struct drm_file *file_priv,
+				    drm_radeon_texture_t * tex,
+				    drm_radeon_tex_image_t * image);
+
+/* r600_blit.c */
+extern int
+r600_prepare_blit_copy(struct drm_device *dev);
+extern void
+r600_done_blit_copy(struct drm_device *dev);
+extern void
+r600_blit_copy(struct drm_device *dev,
+	       uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
+	       int size_bytes);
+extern void
+r600_blit_swap(struct drm_device *dev,
+	       uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
+	       int sx, int sy, int dx, int dy,
+	       int w, int h, int src_pitch, int dst_pitch, int cpp);
+
+/* radeon_state.c */
+extern void radeon_cp_discard_buffer(struct drm_device * dev, struct drm_buf * buf);
+
+/* radeon_cs.c */
+extern int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *fpriv);
+extern int r600_cs_init(struct drm_device *dev);
 
 /* Flags for stats.boxes
  */
@@ -685,6 +761,7 @@ extern void r600_page_table_cleanup(stru
 
 /* pipe config regs */
 #define R400_GB_PIPE_SELECT             0x402c
+#define RV530_GB_PIPE_SELECT2           0x4124
 #define R500_DYN_SCLK_PWMEM_PIPE        0x000d /* PLL */
 #define R300_GB_TILE_CONFIG             0x4018
 #       define R300_ENABLE_TILING       (1 << 0)
@@ -1827,26 +1904,38 @@ do {									\
  */
 
 #define RADEON_WAIT_UNTIL_2D_IDLE() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_3D_IDLE() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_3D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_IDLE() do {					\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
 		   RADEON_WAIT_3D_IDLECLEAN |				\
 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
 } while (0)
 
 #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do {				\
-	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)        \
+		OUT_RING( CP_PACKET0( R600_WAIT_UNTIL, 0 ) );           \
+	else                                                            \
+		OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );         \
 	OUT_RING( RADEON_WAIT_CRTC_PFLIP );				\
 } while (0)
 
@@ -1961,14 +2050,17 @@ do {								\
 
 #define RING_LOCALS	int write, _nr, _align_nr; unsigned int mask; u32 *ring;
 
+#define RADEON_RING_ALIGN 16
+
 #define BEGIN_RING( n ) do {						\
 	if ( RADEON_VERBOSE ) {						\
 		DRM_INFO( "BEGIN_RING( %d )\n", (n));			\
 	}								\
-	_align_nr = (n + 0xf) & ~0xf;					\
-	if (dev_priv->ring.space <= (_align_nr * sizeof(u32))) {	\
-                COMMIT_RING();						\
-		radeon_wait_ring( dev_priv, _align_nr * sizeof(u32));	\
+	_align_nr = RADEON_RING_ALIGN - ((dev_priv->ring.tail + n) & (RADEON_RING_ALIGN - 1)); \
+	_align_nr += n;							\
+	if ( dev_priv->ring.space <= (_align_nr) * sizeof(u32) ) {	\
+		COMMIT_RING();						\
+		radeon_wait_ring( dev_priv, (_align_nr) * sizeof(u32) ); \
 	}								\
 	_nr = n; dev_priv->ring.space -= (n) * sizeof(u32);		\
 	ring = dev_priv->ring.start;					\

Modified: stable/7/sys/dev/drm/radeon_irq.c
==============================================================================
--- stable/7/sys/dev/drm/radeon_irq.c	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/radeon_irq.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -194,6 +194,9 @@ irqreturn_t radeon_driver_irq_handler(DR
 	u32 r500_disp_int;
 	u32 tmp;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return IRQ_NONE;
+
 	/* Only consider the bits we're interested in - others could be used
 	 * outside the DRM
 	 */
@@ -323,6 +326,9 @@ int radeon_irq_emit(struct drm_device *d
 	drm_radeon_irq_emit_t *emit = data;
 	int result;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return -EINVAL;
+
 	LOCK_TEST_WITH_RETURN(dev, file_priv);
 
 	if (!dev_priv) {
@@ -363,6 +369,9 @@ void radeon_driver_irq_preinstall(struct
 	    (drm_radeon_private_t *) dev->dev_private;
 	u32 dummy;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return;
+
 	/* Disable *all* interrupts */
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
 		RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
@@ -380,6 +389,9 @@ int radeon_driver_irq_postinstall(struct
 	atomic_set(&dev_priv->swi_emitted, 0);
 	DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return 0;
+
 	radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1);
 
 	return 0;
@@ -394,6 +406,9 @@ void radeon_driver_irq_uninstall(struct 
 
 	dev_priv->irq_enabled = 0;
 
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		return;
+
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
 		RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
 	/* Disable *all* interrupts */

Modified: stable/7/sys/dev/drm/radeon_state.c
==============================================================================
--- stable/7/sys/dev/drm/radeon_state.c	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/dev/drm/radeon_state.c	Fri Oct 30 16:35:47 2009	(r198686)
@@ -1541,7 +1541,7 @@ static void radeon_cp_dispatch_vertex(st
 	} while (i < nbox);
 }
 
-static void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_buf *buf)
+void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_buf *buf)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
@@ -2202,7 +2202,10 @@ static int radeon_cp_swap(struct drm_dev
 	if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
 		sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
 
-	radeon_cp_dispatch_swap(dev);
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		r600_cp_dispatch_swap(dev);
+	else
+		radeon_cp_dispatch_swap(dev);
 	sarea_priv->ctx_owner = 0;
 
 	COMMIT_RING();
@@ -2399,7 +2402,10 @@ static int radeon_cp_texture(struct drm_
 	RING_SPACE_TEST_WITH_RETURN(dev_priv);
 	VB_AGE_TEST_WITH_RETURN(dev_priv);
 
-	ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image);
+	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+		ret = r600_cp_dispatch_texture(dev, file_priv, tex, &image);
+	else
+		ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image);
 
 	return ret;
 }
@@ -3018,7 +3024,10 @@ static int radeon_cp_getparam(struct drm
 		value = GET_SCRATCH(dev_priv, 2);
 		break;
 	case RADEON_PARAM_IRQ_NR:
-		value = dev->irq;
+		if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
+			value = 0;
+		else
+			value = dev->irq;
 		break;
 	case RADEON_PARAM_GART_BASE:
 		value = dev_priv->gart_vm_start;
@@ -3072,6 +3081,9 @@ static int radeon_cp_getparam(struct drm
 	case RADEON_PARAM_NUM_GB_PIPES:
 		value = dev_priv->num_gb_pipes;
 		break;
+	case RADEON_PARAM_NUM_Z_PIPES:
+		value = dev_priv->num_z_pipes;
+		break;
 	default:
 		DRM_DEBUG("Invalid parameter %d\n", param->param);
 		return -EINVAL;
@@ -3156,6 +3168,14 @@ void radeon_driver_preclose(struct drm_d
 void radeon_driver_lastclose(struct drm_device *dev)
 {
 	radeon_surfaces_release(PCIGART_FILE_PRIV, dev->dev_private);
+	if (dev->dev_private) {
+		drm_radeon_private_t *dev_priv = dev->dev_private;
+
+		if (dev_priv->sarea_priv &&
+		    dev_priv->sarea_priv->pfCurrentPage != 0)
+			radeon_cp_dispatch_flip(dev);
+	}
+
 	radeon_do_release(dev);
 }
 
@@ -3216,7 +3236,8 @@ struct drm_ioctl_desc radeon_ioctls[] = 
 	DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH)
+	DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_RADEON_CS, radeon_cs_ioctl, DRM_AUTH)
 };
 
 int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls);

Modified: stable/7/sys/modules/drm/radeon/Makefile
==============================================================================
--- stable/7/sys/modules/drm/radeon/Makefile	Fri Oct 30 16:32:35 2009	(r198685)
+++ stable/7/sys/modules/drm/radeon/Makefile	Fri Oct 30 16:35:47 2009	(r198686)
@@ -2,8 +2,8 @@
 
 .PATH:	${.CURDIR}/../../../dev/drm
 KMOD	= radeon
-SRCS	= r300_cmdbuf.c r600_cp.c radeon_cp.c radeon_drv.c radeon_irq.c \
-	radeon_mem.c radeon_state.c
+SRCS	= r300_cmdbuf.c r600_blit.c r600_cp.c radeon_cp.c radeon_cs.c \
+	radeon_drv.c radeon_irq.c radeon_mem.c radeon_state.c
 SRCS	+=device_if.h bus_if.h pci_if.h opt_drm.h
 
 .include 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:37:58 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E73C9106568B;
	Fri, 30 Oct 2009 16:37:58 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BAC898FC13;
	Fri, 30 Oct 2009 16:37:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGbwqF051483;
	Fri, 30 Oct 2009 16:37:58 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGbwgG051480;
	Fri, 30 Oct 2009 16:37:58 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301637.n9UGbwgG051480@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:37:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198687 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/drm dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:37:59 -0000

Author: rnoland
Date: Fri Oct 30 16:37:58 2009
New Revision: 198687
URL: http://svn.freebsd.org/changeset/base/198687

Log:
  MFC r197951
  
  Add support for Intel G41 chipset

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/drm/drm_pciids.h
  stable/8/sys/dev/drm/i915_drv.h
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/drm/drm_pciids.h
==============================================================================
--- stable/8/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:35:47 2009	(r198686)
+++ stable/8/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:37:58 2009	(r198687)
@@ -552,6 +552,7 @@
 	{0x8086, 0x2E02, CHIP_I9XX|CHIP_I965, "Intel Integrated Graphics Device"}, \
 	{0x8086, 0x2E12, CHIP_I9XX|CHIP_I965, "Intel Q45/Q43"}, \
 	{0x8086, 0x2E22, CHIP_I9XX|CHIP_I965, "Intel G45/G43"}, \
+	{0x8086, 0x2E32, CHIP_I9XX|CHIP_I965, "Intel G41"}, \
 	{0, 0, 0, NULL}
 
 #define imagine_PCI_IDS \

Modified: stable/8/sys/dev/drm/i915_drv.h
==============================================================================
--- stable/8/sys/dev/drm/i915_drv.h	Fri Oct 30 16:35:47 2009	(r198686)
+++ stable/8/sys/dev/drm/i915_drv.h	Fri Oct 30 16:37:58 2009	(r198687)
@@ -644,7 +644,8 @@ extern int i915_wait_ring(struct drm_dev
 		       (dev)->pci_device == 0x2A42 || \
 		       (dev)->pci_device == 0x2E02 || \
 		       (dev)->pci_device == 0x2E12 || \
-		       (dev)->pci_device == 0x2E22)
+		       (dev)->pci_device == 0x2E22 || \
+		       (dev)->pci_device == 0x2E32)
 
 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
 
@@ -653,6 +654,7 @@ extern int i915_wait_ring(struct drm_dev
 #define IS_G4X(dev) ((dev)->pci_device == 0x2E02 || \
 		     (dev)->pci_device == 0x2E12 || \
 		     (dev)->pci_device == 0x2E22 || \
+		     (dev)->pci_device == 0x2E32 || \
 		     IS_GM45(dev))
 
 #define IS_G33(dev)    ((dev)->pci_device == 0x29C2 ||	\

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:38:53 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 985F8106566B;
	Fri, 30 Oct 2009 16:38:53 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8672C8FC08;
	Fri, 30 Oct 2009 16:38:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGcrB6051539;
	Fri, 30 Oct 2009 16:38:53 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGcrt5051536;
	Fri, 30 Oct 2009 16:38:53 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301638.n9UGcrt5051536@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:38:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198688 - in stable/7/sys: . contrib/pf dev/drm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:38:53 -0000

Author: rnoland
Date: Fri Oct 30 16:38:53 2009
New Revision: 198688
URL: http://svn.freebsd.org/changeset/base/198688

Log:
  MFC r197951
  
  Add support for Intel G41 chipset

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/drm/drm_pciids.h
  stable/7/sys/dev/drm/i915_drv.h

Modified: stable/7/sys/dev/drm/drm_pciids.h
==============================================================================
--- stable/7/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:37:58 2009	(r198687)
+++ stable/7/sys/dev/drm/drm_pciids.h	Fri Oct 30 16:38:53 2009	(r198688)
@@ -552,6 +552,7 @@
 	{0x8086, 0x2E02, CHIP_I9XX|CHIP_I965, "Intel Integrated Graphics Device"}, \
 	{0x8086, 0x2E12, CHIP_I9XX|CHIP_I965, "Intel Q45/Q43"}, \
 	{0x8086, 0x2E22, CHIP_I9XX|CHIP_I965, "Intel G45/G43"}, \
+	{0x8086, 0x2E32, CHIP_I9XX|CHIP_I965, "Intel G41"}, \
 	{0, 0, 0, NULL}
 
 #define imagine_PCI_IDS \

Modified: stable/7/sys/dev/drm/i915_drv.h
==============================================================================
--- stable/7/sys/dev/drm/i915_drv.h	Fri Oct 30 16:37:58 2009	(r198687)
+++ stable/7/sys/dev/drm/i915_drv.h	Fri Oct 30 16:38:53 2009	(r198688)
@@ -644,7 +644,8 @@ extern int i915_wait_ring(struct drm_dev
 		       (dev)->pci_device == 0x2A42 || \
 		       (dev)->pci_device == 0x2E02 || \
 		       (dev)->pci_device == 0x2E12 || \
-		       (dev)->pci_device == 0x2E22)
+		       (dev)->pci_device == 0x2E22 || \
+		       (dev)->pci_device == 0x2E32)
 
 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
 
@@ -653,6 +654,7 @@ extern int i915_wait_ring(struct drm_dev
 #define IS_G4X(dev) ((dev)->pci_device == 0x2E02 || \
 		     (dev)->pci_device == 0x2E12 || \
 		     (dev)->pci_device == 0x2E22 || \
+		     (dev)->pci_device == 0x2E32 || \
 		     IS_GM45(dev))
 
 #define IS_G33(dev)    ((dev)->pci_device == 0x29C2 ||	\

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:43:28 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9445C1065676;
	Fri, 30 Oct 2009 16:43:28 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 811BB8FC22;
	Fri, 30 Oct 2009 16:43:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGhSiB051734;
	Fri, 30 Oct 2009 16:43:28 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGhShf051732;
	Fri, 30 Oct 2009 16:43:28 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301643.n9UGhShf051732@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:43:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198689 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/agp dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:43:28 -0000

Author: rnoland
Date: Fri Oct 30 16:43:28 2009
New Revision: 198689
URL: http://svn.freebsd.org/changeset/base/198689

Log:
  MFC r197950
  
  Add pci id's for Intel G41 chipset

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/agp/agp_i810.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/agp/agp_i810.c
==============================================================================
--- stable/8/sys/dev/agp/agp_i810.c	Fri Oct 30 16:38:53 2009	(r198688)
+++ stable/8/sys/dev/agp/agp_i810.c	Fri Oct 30 16:43:28 2009	(r198689)
@@ -175,6 +175,8 @@ static const struct agp_i810_match {
 	    "Intel Q45 SVGA controller"},
 	{0x2E228086, CHIP_G4X, 0x00020000,
 	    "Intel G45 SVGA controller"},
+	{0x2E328086, CHIP_G4X, 0x00020000,
+	    "Intel G41 SVGA controller"},
 	{0, 0, 0, NULL}
 };
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 16:49:38 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EAE7510656A5;
	Fri, 30 Oct 2009 16:49:38 +0000 (UTC)
	(envelope-from rnoland@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D89B78FC1A;
	Fri, 30 Oct 2009 16:49:38 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UGnctI051940;
	Fri, 30 Oct 2009 16:49:38 GMT (envelope-from rnoland@svn.freebsd.org)
Received: (from rnoland@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UGncVP051938;
	Fri, 30 Oct 2009 16:49:38 GMT (envelope-from rnoland@svn.freebsd.org)
Message-Id: <200910301649.n9UGncVP051938@svn.freebsd.org>
From: Robert Noland 
Date: Fri, 30 Oct 2009 16:49:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198690 - in stable/7/sys: . contrib/pf pci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 16:49:39 -0000

Author: rnoland
Date: Fri Oct 30 16:49:38 2009
New Revision: 198690
URL: http://svn.freebsd.org/changeset/base/198690

Log:
  MFC r197950 (record only)
  
  Add pci id's for Intel G41 chipset

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/pci/agp_i810.c

Modified: stable/7/sys/pci/agp_i810.c
==============================================================================
--- stable/7/sys/pci/agp_i810.c	Fri Oct 30 16:43:28 2009	(r198689)
+++ stable/7/sys/pci/agp_i810.c	Fri Oct 30 16:49:38 2009	(r198690)
@@ -175,6 +175,8 @@ static const struct agp_i810_match {
 	    "Intel Q45 SVGA controller"},
 	{0x2E228086, CHIP_G4X, 0x00020000,
 	    "Intel G45 SVGA controller"},
+	{0x2E328086, CHIP_G4X, 0x00020000,
+	    "Intel G41 SVGA controller"},
 	{0, 0, 0, NULL}
 };
 

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 17:28:36 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6C977106566C;
	Fri, 30 Oct 2009 17:28:36 +0000 (UTC)
	(envelope-from rafan@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5A6C68FC0C;
	Fri, 30 Oct 2009 17:28:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UHSaIL052958;
	Fri, 30 Oct 2009 17:28:36 GMT (envelope-from rafan@svn.freebsd.org)
Received: (from rafan@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UHSaw7052956;
	Fri, 30 Oct 2009 17:28:36 GMT (envelope-from rafan@svn.freebsd.org)
Message-Id: <200910301728.n9UHSaw7052956@svn.freebsd.org>
From: Rong-En Fan 
Date: Fri, 30 Oct 2009 17:28:36 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198693 - in stable/8/contrib/ncurses: . ncurses/base
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 17:28:36 -0000

Author: rafan
Date: Fri Oct 30 17:28:35 2009
New Revision: 198693
URL: http://svn.freebsd.org/changeset/base/198693

Log:
  MFC r198490
  
   Pull upstream patch to fix ee(1) crash when received SIGWINCH:
  
     modify _nc_wgetch() to check for a -1 in the fifo, e.g., after a
     SIGWINCH, and discard that value, to avoid confusing application
     (patch by Eygene Ryabinkin, FreeBSD bin/136223).
  
  PR:		136223
  Submitted by:	Eygene Ryabinkin
  Obtained from:	ncurses-5.7-20091024 snapshot

Modified:
  stable/8/contrib/ncurses/   (props changed)
  stable/8/contrib/ncurses/ncurses/base/lib_getch.c

Modified: stable/8/contrib/ncurses/ncurses/base/lib_getch.c
==============================================================================
--- stable/8/contrib/ncurses/ncurses/base/lib_getch.c	Fri Oct 30 16:59:58 2009	(r198692)
+++ stable/8/contrib/ncurses/ncurses/base/lib_getch.c	Fri Oct 30 17:28:35 2009	(r198693)
@@ -476,6 +476,12 @@ _nc_wgetch(WINDOW *win,
 	    /* resizeterm can push KEY_RESIZE */
 	    if (cooked_key_in_fifo()) {
 		*result = fifo_pull(sp);
+		/*
+		 * Get the ERR from queue -- it is from WINCH,
+		 * so we should take it out, the "error" is handled.
+		 */
+		if (fifo_peek(sp) == -1)
+		    fifo_pull(sp);
 		returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
 	    }
 	}

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 19:25:14 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0DAB21065676;
	Fri, 30 Oct 2009 19:25:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D68DA8FC22;
	Fri, 30 Oct 2009 19:25:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UJPDsk055527;
	Fri, 30 Oct 2009 19:25:13 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UJPDhm055523;
	Fri, 30 Oct 2009 19:25:13 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200910301925.n9UJPDhm055523@svn.freebsd.org>
From: John Baldwin 
Date: Fri, 30 Oct 2009 19:25:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198698 - in stable/7/sys: . conf contrib/pf
	pc98/include pc98/pc98
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 19:25:14 -0000

Author: jhb
Date: Fri Oct 30 19:25:13 2009
New Revision: 198698
URL: http://svn.freebsd.org/changeset/base/198698

Log:
  MFC 192106: Port mca(4) to pc98.
  
  Pointy hat to:	jhb

Added:
  stable/7/sys/pc98/include/mca.h
     - copied unchanged from r192106, head/sys/pc98/include/mca.h
Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/conf/files.pc98
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/pc98/pc98/machdep.c

Modified: stable/7/sys/conf/files.pc98
==============================================================================
--- stable/7/sys/conf/files.pc98	Fri Oct 30 18:30:13 2009	(r198697)
+++ stable/7/sys/conf/files.pc98	Fri Oct 30 19:25:13 2009	(r198698)
@@ -157,6 +157,7 @@ i386/i386/k6_mem.c		optional mem
 i386/i386/legacy.c		standard
 i386/i386/local_apic.c		optional apic
 i386/i386/locore.s		standard	no-obj
+i386/i386/mca.c			standard
 i386/i386/mem.c			optional mem
 i386/i386/minidump_machdep.c	standard
 i386/i386/mp_clock.c		optional smp

Copied: stable/7/sys/pc98/include/mca.h (from r192106, head/sys/pc98/include/mca.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/7/sys/pc98/include/mca.h	Fri Oct 30 19:25:13 2009	(r198698, copy of r192106, head/sys/pc98/include/mca.h)
@@ -0,0 +1,6 @@
+/*-
+ * This file is in the public domain.
+ */
+/* $FreeBSD$ */
+
+#include 

Modified: stable/7/sys/pc98/pc98/machdep.c
==============================================================================
--- stable/7/sys/pc98/pc98/machdep.c	Fri Oct 30 18:30:13 2009	(r198697)
+++ stable/7/sys/pc98/pc98/machdep.c	Fri Oct 30 19:25:13 2009	(r198698)
@@ -112,6 +112,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -257,6 +258,8 @@ cpu_startup(dummy)
 	vm_pager_bufferinit();
 
 	cpu_setregs();
+
+	mca_init();
 }
 
 /*

From owner-svn-src-stable@FreeBSD.ORG  Fri Oct 30 19:59:51 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15E3010656AA;
	Fri, 30 Oct 2009 19:59:51 +0000 (UTC)
	(envelope-from rpaulo@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 01AC88FC2B;
	Fri, 30 Oct 2009 19:59:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UJxodv056194;
	Fri, 30 Oct 2009 19:59:50 GMT (envelope-from rpaulo@svn.freebsd.org)
Received: (from rpaulo@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UJxocG056188;
	Fri, 30 Oct 2009 19:59:50 GMT (envelope-from rpaulo@svn.freebsd.org)
Message-Id: <200910301959.n9UJxocG056188@svn.freebsd.org>
From: Rui Paulo 
Date: Fri, 30 Oct 2009 19:59:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198699 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci net80211
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 30 Oct 2009 19:59:51 -0000

Author: rpaulo
Date: Fri Oct 30 19:59:50 2009
New Revision: 198699
URL: http://svn.freebsd.org/changeset/base/198699

Log:
  MFC r198230, r198242, r198260, r198346, r198369, r198384:
  
      More mesh fixes to comply with latest draft.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net80211/ieee80211_hwmp.c
  stable/8/sys/net80211/ieee80211_mesh.c
  stable/8/sys/net80211/ieee80211_mesh.h
  stable/8/sys/net80211/ieee80211_output.c
  stable/8/sys/net80211/ieee80211_proto.h

Modified: stable/8/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- stable/8/sys/net80211/ieee80211_hwmp.c	Fri Oct 30 19:25:13 2009	(r198698)
+++ stable/8/sys/net80211/ieee80211_hwmp.c	Fri Oct 30 19:59:50 2009	(r198699)
@@ -148,7 +148,7 @@ typedef uint32_t ieee80211_hwmp_seq;
 struct ieee80211_hwmp_route {
 	ieee80211_hwmp_seq	hr_seq;		/* last HWMP seq seen from dst*/
 	ieee80211_hwmp_seq	hr_preqid;	/* last PREQ ID seen from dst */
-	ieee80211_hwmp_seq	hr_targetseq;	/* seq. no. on our latest PREQ*/
+	ieee80211_hwmp_seq	hr_origseq;	/* seq. no. on our latest PREQ*/
 	int			hr_preqretries;
 };
 struct ieee80211_hwmp_state {
@@ -548,7 +548,7 @@ hwmp_add_meshperr(uint8_t *frm, const st
 	*frm++ = perr->perr_ttl;
 	*frm++ = perr->perr_ndests;
 	for (i = 0; i < perr->perr_ndests; i++) {
-		*frm += perr->perr_dests[i].dest_flags;
+		*frm++ = perr->perr_dests[i].dest_flags;
 		IEEE80211_ADDR_COPY(frm, perr->perr_dests[i].dest_addr);
 		frm += 6;
 		ADDWORD(frm, perr->perr_dests[i].dest_seq);
@@ -653,6 +653,7 @@ hwmp_rootmode_rann_cb(void *arg)
 	IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss,
 	    "%s", "send broadcast RANN");
 
+	rann.rann_flags = 0;
 	if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL)
 		rann.rann_flags |= IEEE80211_MESHRANN_FLAGS_PR;
 	rann.rann_hopcount = 0;
@@ -733,12 +734,12 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 		prep.prep_flags = 0;
 		prep.prep_hopcount = 0;
 		prep.prep_ttl = ms->ms_ttl;
-		IEEE80211_ADDR_COPY(prep.prep_targetaddr, preq->preq_origaddr);
-		prep.prep_targetseq = preq->preq_origseq;
+		IEEE80211_ADDR_COPY(prep.prep_targetaddr, vap->iv_myaddr);
+		prep.prep_targetseq = ++hs->hs_seq;
 		prep.prep_lifetime = preq->preq_lifetime;
 		prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
-		IEEE80211_ADDR_COPY(prep.prep_origaddr, vap->iv_myaddr);
-		prep.prep_origseq = ++hs->hs_seq;
+		IEEE80211_ADDR_COPY(prep.prep_origaddr, preq->preq_origaddr);
+		prep.prep_origseq = preq->preq_origseq;
 		hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep);
 		/*
 		 * Build the reverse path, if we don't have it already.
@@ -784,13 +785,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 			prep.prep_flags = 0;
 			prep.prep_hopcount = 0;
 			prep.prep_ttl = ms->ms_ttl;
-			IEEE80211_ADDR_COPY(prep.prep_origaddr, vap->iv_myaddr);
+			IEEE80211_ADDR_COPY(prep.prep_origaddr, rootmac);
 			prep.prep_origseq = preq->preq_origseq;
-			prep.prep_targetseq = ++hs->hs_seq;
 			prep.prep_lifetime = preq->preq_lifetime;
 			prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
-			IEEE80211_ADDR_COPY(prep.prep_targetaddr, rootmac);
-			prep.prep_targetseq = PREQ_TSEQ(0);
+			IEEE80211_ADDR_COPY(prep.prep_targetaddr,
+			    vap->iv_myaddr);
+			prep.prep_targetseq = ++hs->hs_seq;
 			hwmp_send_prep(vap->iv_bss, vap->iv_myaddr,
 			    broadcastaddr, &prep);
 		}
@@ -848,13 +849,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 				prep.prep_hopcount = rt->rt_nhops + 1;
 				prep.prep_ttl = ms->ms_ttl;
 				IEEE80211_ADDR_COPY(&prep.prep_targetaddr,
-				    preq->preq_origaddr);
+				    PREQ_TADDR(0));
 				prep.prep_targetseq = hrorig->hr_seq;
 				prep.prep_lifetime = preq->preq_lifetime;
 				prep.prep_metric = rt->rt_metric +
 				    ms->ms_pmetric->mpm_metric(ni);
 				IEEE80211_ADDR_COPY(&prep.prep_origaddr,
-				    PREQ_TADDR(0));
+				    preq->preq_origaddr);
 				prep.prep_origseq = hrorig->hr_seq;
 				hwmp_send_prep(ni, vap->iv_myaddr,
 				    broadcastaddr, &prep);
@@ -951,19 +952,19 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 		return;
 
 	IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-	    "received PREP from %s", ether_sprintf(prep->prep_origaddr));
+	    "received PREP from %s", ether_sprintf(prep->prep_targetaddr));
 
-	rt = ieee80211_mesh_rt_find(vap, prep->prep_origaddr);
+	rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr);
 	if (rt == NULL) {
 		/*
 		 * If we have no entry this could be a reply to a root PREQ.
 		 */
 		if (hs->hs_rootmode != IEEE80211_HWMP_ROOTMODE_DISABLED) {
-			rt = ieee80211_mesh_rt_add(vap, prep->prep_origaddr);
+			rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr);
 			if (rt == NULL) {
 				IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP,
 				    ni, "unable to add PREP path to %s",
-				    ether_sprintf(prep->prep_origaddr));
+				    ether_sprintf(prep->prep_targetaddr));
 				vap->iv_stats.is_mesh_rtaddfailed++;
 				return;
 			}
@@ -974,7 +975,7 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 			rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID;
 			IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 			    "add root path to %s nhops %d metric %d (PREP)",
-			    ether_sprintf(prep->prep_origaddr),
+			    ether_sprintf(prep->prep_targetaddr),
 			    rt->rt_nhops, rt->rt_metric);
 			return;
 		} 
@@ -984,30 +985,30 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 	 * Sequence number validation.
 	 */
 	hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route);
-	if (HWMP_SEQ_LEQ(prep->prep_origseq, hr->hr_seq)) {
+	if (HWMP_SEQ_LEQ(prep->prep_targetseq, hr->hr_seq)) {
 		IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 		    "discard PREP from %s, old seq no %u <= %u",
-		    ether_sprintf(prep->prep_origaddr),
-		    prep->prep_origseq, hr->hr_seq);
+		    ether_sprintf(prep->prep_targetaddr),
+		    prep->prep_targetseq, hr->hr_seq);
 		return;
 	}
-	hr->hr_seq = prep->prep_origseq;
+	hr->hr_seq = prep->prep_targetseq;
 	/*
 	 * If it's NOT for us, propagate the PREP.
 	 */
-	if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_targetaddr) &&
+	if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) &&
 	    prep->prep_ttl > 1 && prep->prep_hopcount < hs->hs_maxhops) {
 		struct ieee80211_meshprep_ie pprep; /* propagated PREP */
 
 		IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 		    "propagate PREP from %s",
-		    ether_sprintf(prep->prep_origaddr));
+		    ether_sprintf(prep->prep_targetaddr));
 
 		memcpy(&pprep, prep, sizeof(pprep));
 		pprep.prep_hopcount += 1;
 		pprep.prep_ttl -= 1;
 		pprep.prep_metric += ms->ms_pmetric->mpm_metric(ni);
-		IEEE80211_ADDR_COPY(pprep.prep_origaddr, vap->iv_myaddr);
+		IEEE80211_ADDR_COPY(pprep.prep_targetaddr, vap->iv_myaddr);
 		hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep);
 	}
 	hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route);
@@ -1015,9 +1016,9 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 		/* NB: never clobber a proxy entry */;
 		IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 		    "discard PREP for %s, route is marked PROXY",
-		    ether_sprintf(prep->prep_origaddr));
+		    ether_sprintf(prep->prep_targetaddr));
 		vap->iv_stats.is_hwmp_proxy++;
-	} else if (prep->prep_targetseq == hr->hr_targetseq) {
+	} else if (prep->prep_origseq == hr->hr_origseq) {
 		/*
 		 * Check if we already have a path to this node.
 		 * If we do, check if this path reply contains a
@@ -1041,14 +1042,14 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 		} else {
 			IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 			    "ignore PREP for %s, hopcount %d:%d metric %d:%d",
-			    ether_sprintf(prep->prep_origaddr),
+			    ether_sprintf(prep->prep_targetaddr),
 			    rt->rt_nhops, prep->prep_hopcount,
 			    rt->rt_metric, prep->prep_metric);
 		}
 	} else {
 		IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
 		    "discard PREP for %s, wrong seqno %u != %u",
-		    ether_sprintf(prep->prep_origaddr), prep->prep_targetseq,
+		    ether_sprintf(prep->prep_targetaddr), prep->prep_origseq,
 		    hr->hr_seq);
 		vap->iv_stats.is_hwmp_wrongseq++;
 	} 
@@ -1114,6 +1115,7 @@ hwmp_peerdown(struct ieee80211_node *ni)
 	    "%s", "delete route entry");
 	perr.perr_ttl = ms->ms_ttl;
 	perr.perr_ndests = 1;
+	PERR_DFLAGS(0) = 0;
 	if (hr->hr_seq == 0)
 		PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_USN;
 	PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_RC;
@@ -1223,7 +1225,8 @@ hwmp_recv_rann(struct ieee80211vap *vap,
 	struct ieee80211_meshrann_ie prann;
 
 	if (ni == vap->iv_bss ||
-	    ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED)
+	    ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED ||
+	    IEEE80211_ADDR_EQ(rann->rann_addr, vap->iv_myaddr))
 		return;
 
 	rt = ieee80211_mesh_rt_find(vap, rann->rann_addr);
@@ -1305,8 +1308,8 @@ hwmp_discover(struct ieee80211vap *vap,
 		hr = IEEE80211_MESH_ROUTE_PRIV(rt,
 		    struct ieee80211_hwmp_route);
 		if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) {
-			if (hr->hr_targetseq == 0)
-				hr->hr_targetseq = ++hs->hs_seq;
+			if (hr->hr_origseq == 0)
+				hr->hr_origseq = ++hs->hs_seq;
 			rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
 			rt->rt_lifetime =
 			    ticks_to_msecs(ieee80211_hwmp_pathtimeout);
@@ -1324,7 +1327,7 @@ hwmp_discover(struct ieee80211vap *vap,
 			preq.preq_ttl = ms->ms_ttl;
 			preq.preq_id = ++hs->hs_preqid;
 			IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr);
-			preq.preq_origseq = hr->hr_targetseq;
+			preq.preq_origseq = hr->hr_origseq;
 			preq.preq_lifetime = rt->rt_lifetime;
 			preq.preq_metric = rt->rt_metric;
 			preq.preq_tcount = 1;

Modified: stable/8/sys/net80211/ieee80211_mesh.c
==============================================================================
--- stable/8/sys/net80211/ieee80211_mesh.c	Fri Oct 30 19:25:13 2009	(r198698)
+++ stable/8/sys/net80211/ieee80211_mesh.c	Fri Oct 30 19:59:50 2009	(r198699)
@@ -388,8 +388,6 @@ mesh_select_proto_path(struct ieee80211v
 	for (i = 0; i < N(mesh_proto_paths); i++) {
 		if (strcasecmp(mesh_proto_paths[i].mpp_descr, name) == 0) {
 			ms->ms_ppath = &mesh_proto_paths[i];
-			if (vap->iv_state == IEEE80211_S_RUN)
-				vap->iv_newstate(vap, IEEE80211_S_INIT, 0);
 			return 0;
 		}
 	}
@@ -405,8 +403,6 @@ mesh_select_proto_metric(struct ieee8021
 	for (i = 0; i < N(mesh_proto_metrics); i++) {
 		if (strcasecmp(mesh_proto_metrics[i].mpm_descr, name) == 0) {
 			ms->ms_pmetric = &mesh_proto_metrics[i];
-			if (vap->iv_state == IEEE80211_S_RUN)
-				vap->iv_newstate(vap, IEEE80211_S_INIT, 0);
 			return 0;
 		}
 	}
@@ -739,10 +735,12 @@ mesh_linkchange(struct ieee80211_node *n
 	    ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) {
 		KASSERT(ms->ms_neighbors < 65535, ("neighbor count overflow"));
 		ms->ms_neighbors++;
+		ieee80211_beacon_notify(vap, IEEE80211_BEACON_MESHCONF);
 	} else if (ni->ni_mlstate == IEEE80211_NODE_MESH_ESTABLISHED &&
 	    state != IEEE80211_NODE_MESH_ESTABLISHED) {
 		KASSERT(ms->ms_neighbors > 0, ("neighbor count 0"));
 		ms->ms_neighbors--;
+		ieee80211_beacon_notify(vap, IEEE80211_BEACON_MESHCONF);
 	}
 	ni->ni_mlstate = state;
 	switch (state) {
@@ -2552,6 +2550,18 @@ ieee80211_mesh_init_neighbor(struct ieee
 	ieee80211_parse_meshid(ni, sp->meshid);
 }
 
+void
+ieee80211_mesh_update_beacon(struct ieee80211vap *vap,
+	struct ieee80211_beacon_offsets *bo)
+{
+	KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a MBSS vap"));
+
+	if (isset(bo->bo_flags, IEEE80211_BEACON_MESHCONF)) {
+		(void)ieee80211_add_meshconf(bo->bo_meshconf, vap);
+		clrbit(bo->bo_flags, IEEE80211_BEACON_MESHCONF);
+	}
+}
+
 static int
 mesh_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
 {

Modified: stable/8/sys/net80211/ieee80211_mesh.h
==============================================================================
--- stable/8/sys/net80211/ieee80211_mesh.h	Fri Oct 30 19:25:13 2009	(r198698)
+++ stable/8/sys/net80211/ieee80211_mesh.h	Fri Oct 30 19:59:50 2009	(r198699)
@@ -470,6 +470,8 @@ struct ieee80211_scanparams;
 void		ieee80211_mesh_init_neighbor(struct ieee80211_node *,
 		   const struct ieee80211_frame *,
 		   const struct ieee80211_scanparams *);
+void		ieee80211_mesh_update_beacon(struct ieee80211vap *,
+		    struct ieee80211_beacon_offsets *);
 
 /*
  * Return non-zero if proxy operation is enabled.

Modified: stable/8/sys/net80211/ieee80211_output.c
==============================================================================
--- stable/8/sys/net80211/ieee80211_output.c	Fri Oct 30 19:25:13 2009	(r198698)
+++ stable/8/sys/net80211/ieee80211_output.c	Fri Oct 30 19:59:50 2009	(r198699)
@@ -2658,6 +2658,7 @@ ieee80211_beacon_construct(struct mbuf *
 #ifdef IEEE80211_SUPPORT_MESH
 	if (vap->iv_opmode == IEEE80211_M_MBSS) {
 		frm = ieee80211_add_meshid(frm, vap);
+		bo->bo_meshconf = frm;
 		frm = ieee80211_add_meshconf(frm, vap);
 	}
 #endif
@@ -2763,13 +2764,7 @@ ieee80211_beacon_alloc(struct ieee80211_
 	*(uint16_t *)wh->i_dur = 0;
 	IEEE80211_ADDR_COPY(wh->i_addr1, ifp->if_broadcastaddr);
 	IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr);
-#ifdef IEEE80211_SUPPORT_MESH
-	if (vap->iv_opmode == IEEE80211_M_MBSS) {
-		static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
-		IEEE80211_ADDR_COPY(wh->i_addr3, zerobssid);
-	} else
-#endif
-		IEEE80211_ADDR_COPY(wh->i_addr3, ni->ni_bssid);
+	IEEE80211_ADDR_COPY(wh->i_addr3, ni->ni_bssid);
 	*(uint16_t *)wh->i_seq = 0;
 
 	return m;
@@ -2874,6 +2869,11 @@ ieee80211_beacon_update(struct ieee80211
 		ieee80211_tdma_update_beacon(vap, bo);
 	}
 #endif
+#ifdef IEEE80211_SUPPORT_MESH
+	if (vap->iv_opmode == IEEE80211_M_MBSS)
+		ieee80211_mesh_update_beacon(vap, bo);
+#endif
+
 	if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
 	    vap->iv_opmode == IEEE80211_M_MBSS) {	/* NB: no IBSS support*/
 		struct ieee80211_tim_ie *tie =
@@ -2928,6 +2928,9 @@ ieee80211_beacon_update(struct ieee80211
 #ifdef IEEE80211_TDMA_SUPPORT
 				bo->bo_tdma += adjust;
 #endif
+#ifdef IEEE80211_MESH_SUPPORT
+				bo->bo_meshconf += adjust;
+#endif
 				bo->bo_appie += adjust;
 				bo->bo_wme += adjust;
 				bo->bo_csa += adjust;
@@ -2979,6 +2982,9 @@ ieee80211_beacon_update(struct ieee80211
 #ifdef IEEE80211_TDMA_SUPPORT
 				bo->bo_tdma += sizeof(*csa);
 #endif
+#ifdef IEEE80211_MESH_SUPPORT
+				bo->bo_meshconf += sizeof(*csa);
+#endif
 				bo->bo_appie += sizeof(*csa);
 				bo->bo_csa_trailer_len += sizeof(*csa);
 				bo->bo_tim_trailer_len += sizeof(*csa);

Modified: stable/8/sys/net80211/ieee80211_proto.h
==============================================================================
--- stable/8/sys/net80211/ieee80211_proto.h	Fri Oct 30 19:25:13 2009	(r198698)
+++ stable/8/sys/net80211/ieee80211_proto.h	Fri Oct 30 19:59:50 2009	(r198699)
@@ -317,7 +317,8 @@ struct ieee80211_beacon_offsets {
 	uint16_t	bo_appie_len;	/* AppIE length in bytes */
 	uint16_t	bo_csa_trailer_len;;
 	uint8_t		*bo_csa;	/* start of CSA element */
-	uint8_t		*bo_spare[4];
+	uint8_t		*bo_meshconf;	/* start of MESHCONF element */
+	uint8_t		*bo_spare[3];
 };
 struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *,
 		struct ieee80211_beacon_offsets *);
@@ -345,6 +346,7 @@ enum {
 	IEEE80211_BEACON_CSA	= 7,	/* Channel Switch Announcement */
 	IEEE80211_BEACON_TDMA	= 9,	/* TDMA Info */
 	IEEE80211_BEACON_ATH	= 10,	/* ATH parameters */
+	IEEE80211_BEACON_MESHCONF = 11,	/* Mesh Configuration */
 };
 int	ieee80211_beacon_update(struct ieee80211_node *,
 		struct ieee80211_beacon_offsets *, struct mbuf *, int mcast);

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 06:35:40 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F186B106566B;
	Sat, 31 Oct 2009 06:35:40 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DD65E8FC16;
	Sat, 31 Oct 2009 06:35:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9V6Ze6g071323;
	Sat, 31 Oct 2009 06:35:40 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9V6ZewN071320;
	Sat, 31 Oct 2009 06:35:40 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <200910310635.n9V6ZewN071320@svn.freebsd.org>
From: Edwin Groothuis 
Date: Sat, 31 Oct 2009 06:35:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198704 - in stable/8: include lib/libc lib/libc/gen
	lib/libc/locale lib/libc/stdio lib/libc/stdtime
	lib/libc/string usr.bin/locale
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 06:35:41 -0000

Author: edwin
Date: Sat Oct 31 06:35:40 2009
New Revision: 198704
URL: http://svn.freebsd.org/changeset/base/198704

Log:
  MFCs of r197764, r197765, r197766, r197847:
  
  Modified locale(1) to be able to show the altmon_X fields and the
  [cxX]_fmt's.  Also modify the "-k list" option to display only
  fields with a certain prefix.
  
  Add the comment "(FreeBSD only)" to the altmonth_x keywords

Modified:
  stable/8/include/   (props changed)
  stable/8/include/langinfo.h
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/gen/   (props changed)
  stable/8/lib/libc/locale/nl_langinfo.c
  stable/8/lib/libc/stdio/asprintf.c   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/stdtime/localtime.c
  stable/8/lib/libc/string/ffsll.c   (props changed)
  stable/8/lib/libc/string/flsll.c   (props changed)
  stable/8/lib/libc/string/wcpcpy.c   (props changed)
  stable/8/lib/libc/string/wcpncpy.c   (props changed)
  stable/8/usr.bin/locale/   (props changed)
  stable/8/usr.bin/locale/locale.1
  stable/8/usr.bin/locale/locale.c

Modified: stable/8/include/langinfo.h
==============================================================================
--- stable/8/include/langinfo.h	Fri Oct 30 23:33:06 2009	(r198703)
+++ stable/8/include/langinfo.h	Sat Oct 31 06:35:40 2009	(r198704)
@@ -114,6 +114,20 @@ typedef	__nl_item	nl_item;
 #define	D_MD_ORDER	57	/* month/day order (local extension) */
 #endif
 
+/* standalone months forms for %OB */
+#define	ALTMON_1	58
+#define	ALTMON_2	59
+#define	ALTMON_3	60
+#define	ALTMON_4	61
+#define	ALTMON_5	62
+#define	ALTMON_6	63
+#define	ALTMON_7	64
+#define	ALTMON_8	65
+#define	ALTMON_9	66
+#define	ALTMON_10	67
+#define	ALTMON_11	68
+#define	ALTMON_12	69
+
 __BEGIN_DECLS
 char	*nl_langinfo(nl_item);
 __END_DECLS

Modified: stable/8/lib/libc/locale/nl_langinfo.c
==============================================================================
--- stable/8/lib/libc/locale/nl_langinfo.c	Fri Oct 30 23:33:06 2009	(r198703)
+++ stable/8/lib/libc/locale/nl_langinfo.c	Sat Oct 31 06:35:40 2009	(r198704)
@@ -93,6 +93,12 @@ nl_langinfo(nl_item item)
 	case ABMON_9: case ABMON_10: case ABMON_11: case ABMON_12:
 		ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)];
 		break;
+	case ALTMON_1: case ALTMON_2: case ALTMON_3: case ALTMON_4:
+	case ALTMON_5: case ALTMON_6: case ALTMON_7: case ALTMON_8:
+	case ALTMON_9: case ALTMON_10: case ALTMON_11: case ALTMON_12:
+		ret = (char*)
+		    __get_current_time_locale()->alt_month[_REL(ALTMON_1)];
+		break;
 	case ERA:
 		/* XXX: need to be implemented  */
 		ret = "";

Modified: stable/8/lib/libc/stdtime/localtime.c
==============================================================================
--- stable/8/lib/libc/stdtime/localtime.c	Fri Oct 30 23:33:06 2009	(r198703)
+++ stable/8/lib/libc/stdtime/localtime.c	Sat Oct 31 06:35:40 2009	(r198704)
@@ -21,6 +21,7 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "private.h"
@@ -1413,13 +1414,16 @@ const time_t * const	timep;
 	static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER;
 	static pthread_key_t localtime_key = -1;
 	struct tm *p_tm;
+	int r;
 
 	if (__isthreaded != 0) {
 		if (localtime_key < 0) {
 			_pthread_mutex_lock(&localtime_mutex);
 			if (localtime_key < 0) {
-				if (_pthread_key_create(&localtime_key, free) < 0) {
+				if ((r = _pthread_key_create(&localtime_key,
+				    free)) != 0) {
 					_pthread_mutex_unlock(&localtime_mutex);
+					errno = r;
 					return(NULL);
 				}
 			}
@@ -1512,13 +1516,16 @@ const time_t * const	timep;
 	static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
 	static pthread_key_t gmtime_key = -1;
 	struct tm *p_tm;
+	int r;
 
 	if (__isthreaded != 0) {
 		if (gmtime_key < 0) {
 			_pthread_mutex_lock(&gmtime_mutex);
 			if (gmtime_key < 0) {
-				if (_pthread_key_create(&gmtime_key, free) < 0) {
+				if ((r = _pthread_key_create(&gmtime_key,
+				    free)) != 0) {
 					_pthread_mutex_unlock(&gmtime_mutex);
+					errno = r;
 					return(NULL);
 				}
 			}

Modified: stable/8/usr.bin/locale/locale.1
==============================================================================
--- stable/8/usr.bin/locale/locale.1	Fri Oct 30 23:33:06 2009	(r198703)
+++ stable/8/usr.bin/locale/locale.1	Sat Oct 31 06:35:40 2009	(r198704)
@@ -35,8 +35,12 @@
 .Nm
 .Op Fl a | m
 .Nm
-.Op Fl ck
-.Op Ar keyword ...
+.Fl k 
+.Ic list
+.Op Ar prefix
+.Nm
+.Op Fl ck 
+.Ar keyword ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -79,6 +83,8 @@ The special
 specific) keyword
 .Cm list
 can be used to retrieve the human readable list of all available keywords.
+If so,
+a prefix string can be defined to limit the amount of keywords returned.
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO

Modified: stable/8/usr.bin/locale/locale.c
==============================================================================
--- stable/8/usr.bin/locale/locale.c	Fri Oct 30 23:33:06 2009	(r198703)
+++ stable/8/usr.bin/locale/locale.c	Sat Oct 31 06:35:40 2009	(r198704)
@@ -55,7 +55,7 @@ const char *lookup_localecat(int);
 char	*kwval_lconv(int);
 int	kwval_lookup(char *, char **, int *, int *);
 void	showdetails(char *);
-void	showkeywordslist(void);
+void	showkeywordslist(char *substring);
 void	showlocale(void);
 void	usage(void);
 
@@ -190,6 +190,18 @@ struct _kwinfo {
 	{ "abmon_10",		1, LC_TIME,	ABMON_10, "" },
 	{ "abmon_11",		1, LC_TIME,	ABMON_11, "" },
 	{ "abmon_12",		1, LC_TIME,	ABMON_12, "" },
+	{ "altmon_1",		1, LC_TIME,	ALTMON_1, "(FreeBSD only)" },
+	{ "altmon_2",		1, LC_TIME,	ALTMON_2, "(FreeBSD only)" },
+	{ "altmon_3",		1, LC_TIME,	ALTMON_3, "(FreeBSD only)" },
+	{ "altmon_4",		1, LC_TIME,	ALTMON_4, "(FreeBSD only)" },
+	{ "altmon_5",		1, LC_TIME,	ALTMON_5, "(FreeBSD only)" },
+	{ "altmon_6",		1, LC_TIME,	ALTMON_6, "(FreeBSD only)" },
+	{ "altmon_7",		1, LC_TIME,	ALTMON_7, "(FreeBSD only)" },
+	{ "altmon_8",		1, LC_TIME,	ALTMON_8, "(FreeBSD only)" },
+	{ "altmon_9",		1, LC_TIME,	ALTMON_9, "(FreeBSD only)" },
+	{ "altmon_10",		1, LC_TIME,	ALTMON_10, "(FreeBSD only)" },
+	{ "altmon_11",		1, LC_TIME,	ALTMON_11, "(FreeBSD only)" },
+	{ "altmon_12",		1, LC_TIME,	ALTMON_12, "(FreeBSD only)" },
 	{ "era",		1, LC_TIME,	ERA, "(unavailable)" },
 	{ "era_d_fmt",		1, LC_TIME,	ERA_D_FMT, "(unavailable)" },
 	{ "era_d_t_fmt",	1, LC_TIME,	ERA_D_T_FMT, "(unavailable)" },
@@ -217,7 +229,7 @@ main(int argc, char *argv[])
 	int	ch;
 	int	tmp;
 
-	while ((ch = getopt(argc, argv, "ackm")) != -1) {
+	while ((ch = getopt(argc, argv, "ackms:")) != -1) {
 		switch (ch) {
 		case 'a':
 			all_locales = 1;
@@ -265,7 +277,7 @@ main(int argc, char *argv[])
 	if (prt_keywords && argc > 0)
 		while (tmp < argc)
 			if (strcasecmp(argv[tmp++], "list") == 0) {
-				showkeywordslist();
+				showkeywordslist(argv[tmp]);
 				exit(0);
 			}
 
@@ -290,7 +302,8 @@ void
 usage(void)
 {
 	printf("Usage: locale [ -a | -m ]\n"
-               "       locale [ -ck ] name ...\n");
+               "       locale -k list [prefix]\n"
+               "       locale [ -ck ] keyword ...\n");
 	exit(1);
 }
 
@@ -594,6 +607,7 @@ showdetails(char *kw)
 		 * invalid keyword specified.
 		 * XXX: any actions?
 		 */
+		fprintf(stderr, "Unknown keyword: `%s'\n", kw);
 		return;
 	}
 
@@ -639,16 +653,25 @@ lookup_localecat(int cat)
  * Show list of keywords
  */
 void
-showkeywordslist(void)
+showkeywordslist(char *substring)
 {
 	size_t	i;
 
 #define FMT "%-20s %-12s %-7s %-20s\n"
 
-	printf("List of available keywords\n\n");
+	if (substring == NULL)
+		printf("List of available keywords\n\n");
+	else
+		printf("List of available keywords starting with '%s'\n\n",
+		    substring);
 	printf(FMT, "Keyword", "Category", "Type", "Comment");
 	printf("-------------------- ------------ ------- --------------------\n");
 	for (i = 0; i < NKWINFO; i++) {
+		if (substring != NULL) {
+			if (strncmp(kwinfo[i].name, substring,
+			    strlen(substring)) != 0)
+				continue;
+		}
 		printf(FMT,
 			kwinfo[i].name,
 			lookup_localecat(kwinfo[i].catid),

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 10:59:54 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 31CB2106566B;
	Sat, 31 Oct 2009 10:59:54 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1F0398FC0A;
	Sat, 31 Oct 2009 10:59:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VAxslX086155;
	Sat, 31 Oct 2009 10:59:54 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VAxsIR086153;
	Sat, 31 Oct 2009 10:59:54 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910311059.n9VAxsIR086153@svn.freebsd.org>
From: Christian Brueffer 
Date: Sat, 31 Oct 2009 10:59:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198710 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/aic7xxx/aicasm dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 10:59:54 -0000

Author: brueffer
Date: Sat Oct 31 10:59:53 2009
New Revision: 198710
URL: http://svn.freebsd.org/changeset/base/198710

Log:
  MFC: r198327
  
  Add a missing free() call.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/aic7xxx/aicasm/aicasm.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/aic7xxx/aicasm/aicasm.c
==============================================================================
--- stable/8/sys/dev/aic7xxx/aicasm/aicasm.c	Sat Oct 31 10:47:47 2009	(r198709)
+++ stable/8/sys/dev/aic7xxx/aicasm/aicasm.c	Sat Oct 31 10:59:53 2009	(r198710)
@@ -639,6 +639,8 @@ output_listing(char *ifilename)
 		}
 		instrptr++;
 	}
+	free(func_values);
+
 	/* Dump the remainder of the file */
 	while(fgets(buf, sizeof(buf), ifile) != NULL)
 		fprintf(listfile, "             %s", buf);

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 11:08:04 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8EDFA106568D;
	Sat, 31 Oct 2009 11:08:04 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7C29F8FC08;
	Sat, 31 Oct 2009 11:08:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VB84DQ086775;
	Sat, 31 Oct 2009 11:08:04 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VB84JH086773;
	Sat, 31 Oct 2009 11:08:04 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910311108.n9VB84JH086773@svn.freebsd.org>
From: Christian Brueffer 
Date: Sat, 31 Oct 2009 11:08:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198711 - in stable/8/sys: . amd64/include/xen cam/scsi
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 11:08:04 -0000

Author: brueffer
Date: Sat Oct 31 11:08:04 2009
New Revision: 198711
URL: http://svn.freebsd.org/changeset/base/198711

Log:
  MFC: r198356
  
  Fix a memory leak in an error case.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cam/scsi/scsi_low.c
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/cam/scsi/scsi_low.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_low.c	Sat Oct 31 10:59:53 2009	(r198710)
+++ stable/8/sys/cam/scsi/scsi_low.c	Sat Oct 31 11:08:04 2009	(r198711)
@@ -638,7 +638,10 @@ scsi_low_attach_xs(slp)
 		return ENOMEM;
 	splp = SCSI_LOW_MALLOC(sizeof(*splp));
 	if (splp == NULL)
+	{
+		SCSI_LOW_FREE(sap);
 		return ENOMEM;
+	}
 
 	SCSI_LOW_BZERO(sap, sizeof(*sap));
 	SCSI_LOW_BZERO(splp, sizeof(*splp));

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 11:21:45 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EA4EC106566C;
	Sat, 31 Oct 2009 11:21:45 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D8A988FC13;
	Sat, 31 Oct 2009 11:21:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VBLjg1087540;
	Sat, 31 Oct 2009 11:21:45 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VBLjho087538;
	Sat, 31 Oct 2009 11:21:45 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910311121.n9VBLjho087538@svn.freebsd.org>
From: Christian Brueffer 
Date: Sat, 31 Oct 2009 11:21:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198712 - in stable/7/sys: . contrib/pf
	dev/aic7xxx/aicasm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 11:21:46 -0000

Author: brueffer
Date: Sat Oct 31 11:21:45 2009
New Revision: 198712
URL: http://svn.freebsd.org/changeset/base/198712

Log:
  MFC: r198327
  
  Add a missing free() call.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/aic7xxx/aicasm/aicasm.c

Modified: stable/7/sys/dev/aic7xxx/aicasm/aicasm.c
==============================================================================
--- stable/7/sys/dev/aic7xxx/aicasm/aicasm.c	Sat Oct 31 11:08:04 2009	(r198711)
+++ stable/7/sys/dev/aic7xxx/aicasm/aicasm.c	Sat Oct 31 11:21:45 2009	(r198712)
@@ -641,6 +641,8 @@ output_listing(char *ifilename)
 		}
 		instrptr++;
 	}
+	free(func_values);
+
 	/* Dump the remainder of the file */
 	while(fgets(buf, sizeof(buf), ifile) != NULL)
 		fprintf(listfile, "             %s", buf);

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 11:23:54 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 77B6F1065670;
	Sat, 31 Oct 2009 11:23:54 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 666478FC0C;
	Sat, 31 Oct 2009 11:23:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VBNsoD087646;
	Sat, 31 Oct 2009 11:23:54 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VBNsRk087644;
	Sat, 31 Oct 2009 11:23:54 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200910311123.n9VBNsRk087644@svn.freebsd.org>
From: Christian Brueffer 
Date: Sat, 31 Oct 2009 11:23:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198713 - in stable/7/sys: . cam/scsi contrib/pf
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 11:23:54 -0000

Author: brueffer
Date: Sat Oct 31 11:23:54 2009
New Revision: 198713
URL: http://svn.freebsd.org/changeset/base/198713

Log:
  MFC: 198356
  
  Fix a memory leak in an error case.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/cam/scsi/scsi_low.c
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/cam/scsi/scsi_low.c
==============================================================================
--- stable/7/sys/cam/scsi/scsi_low.c	Sat Oct 31 11:21:45 2009	(r198712)
+++ stable/7/sys/cam/scsi/scsi_low.c	Sat Oct 31 11:23:54 2009	(r198713)
@@ -638,7 +638,10 @@ scsi_low_attach_xs(slp)
 		return ENOMEM;
 	splp = SCSI_LOW_MALLOC(sizeof(*splp));
 	if (splp == NULL)
+	{
+		SCSI_LOW_FREE(sap);
 		return ENOMEM;
+	}
 
 	SCSI_LOW_BZERO(sap, sizeof(*sap));
 	SCSI_LOW_BZERO(splp, sizeof(*splp));

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 12:26:41 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5D4B0106566B;
	Sat, 31 Oct 2009 12:26:41 +0000 (UTC)
	(envelope-from antoine@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4AE358FC25;
	Sat, 31 Oct 2009 12:26:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VCQfr7089243;
	Sat, 31 Oct 2009 12:26:41 GMT (envelope-from antoine@svn.freebsd.org)
Received: (from antoine@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VCQfVZ089241;
	Sat, 31 Oct 2009 12:26:41 GMT (envelope-from antoine@svn.freebsd.org)
Message-Id: <200910311226.n9VCQfVZ089241@svn.freebsd.org>
From: Antoine Brodin 
Date: Sat, 31 Oct 2009 12:26:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198715 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci kern
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 12:26:41 -0000

Author: antoine
Date: Sat Oct 31 12:26:40 2009
New Revision: 198715
URL: http://svn.freebsd.org/changeset/base/198715

Log:
  MFC r196891 to stable/8:
    Change w_notrunning and w_stillcold from pointer to array so that sizeof
    returns what is expected.
  
    PR:		kern/138557
    Discussed with:	brucec@
    MFC after:	1 month

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/subr_witness.c

Modified: stable/8/sys/kern/subr_witness.c
==============================================================================
--- stable/8/sys/kern/subr_witness.c	Sat Oct 31 12:22:23 2009	(r198714)
+++ stable/8/sys/kern/subr_witness.c	Sat Oct 31 12:26:40 2009	(r198715)
@@ -469,8 +469,8 @@ static struct witness_lock_order_data *w
 static struct witness_lock_order_hash w_lohash;
 static int w_max_used_index = 0;
 static unsigned int w_generation = 0;
-static const char *w_notrunning = "Witness not running\n";
-static const char *w_stillcold = "Witness is still cold\n";
+static const char w_notrunning[] = "Witness not running\n";
+static const char w_stillcold[] = "Witness is still cold\n";
 
 
 static struct witness_order_list_entry order_lists[] = {

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 17:28:09 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4D3EA106568F;
	Sat, 31 Oct 2009 17:28:09 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3AE488FC0A;
	Sat, 31 Oct 2009 17:28:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VHS8p5097275;
	Sat, 31 Oct 2009 17:28:08 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VHS865097273;
	Sat, 31 Oct 2009 17:28:08 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200910311728.n9VHS865097273@svn.freebsd.org>
From: Alexander Motin 
Date: Sat, 31 Oct 2009 17:28:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198720 - in stable/7/sys: . contrib/pf dev/ata
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 17:28:09 -0000

Author: mav
Date: Sat Oct 31 17:28:08 2009
New Revision: 198720
URL: http://svn.freebsd.org/changeset/base/198720

Log:
  MFC rev. 196893:
  Remove constraint, requiring request data to fulfill controller's alignment
  requirements. It is busdma task, to manage proper alignment by loading
  data to bounce buffers.
  
  PR:		kern/120787, kern/127316

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ata/ata-dma.c

Modified: stable/7/sys/dev/ata/ata-dma.c
==============================================================================
--- stable/7/sys/dev/ata/ata-dma.c	Sat Oct 31 17:06:36 2009	(r198719)
+++ stable/7/sys/dev/ata/ata-dma.c	Sat Oct 31 17:28:08 2009	(r198720)
@@ -233,9 +233,9 @@ ata_dmaload(device_t dev, caddr_t data, 
 	device_printf(dev, "FAILURE - zero length DMA transfer attempted\n");
 	return EIO;
     }
-    if (((uintptr_t)data & (ch->dma->alignment - 1)) ||
-	(count & (ch->dma->alignment - 1))) {
-	device_printf(dev, "FAILURE - non aligned DMA transfer attempted\n");
+    if (count & (ch->dma->alignment - 1)) {
+	device_printf(dev, "FAILURE - odd-sized DMA transfer attempt %d %% %d\n",
+	    count, ch->dma->alignment);
 	return EIO;
     }
     if (count > ch->dma->max_iosize) {

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 18:18:33 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1E127106566B;
	Sat, 31 Oct 2009 18:18:33 +0000 (UTC) (envelope-from alc@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0AE558FC32;
	Sat, 31 Oct 2009 18:18:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VIIWup098747;
	Sat, 31 Oct 2009 18:18:32 GMT (envelope-from alc@svn.freebsd.org)
Received: (from alc@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VIIWrY098745;
	Sat, 31 Oct 2009 18:18:32 GMT (envelope-from alc@svn.freebsd.org)
Message-Id: <200910311818.n9VIIWrY098745@svn.freebsd.org>
From: Alan Cox 
Date: Sat, 31 Oct 2009 18:18:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198726 - in stable/8/sys: . amd64/include/xen
	cddl/contrib/opensolaris contrib/dev/acpica contrib/pf
	dev/xen/xenpci vm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 18:18:33 -0000

Author: alc
Date: Sat Oct 31 18:18:32 2009
New Revision: 198726
URL: http://svn.freebsd.org/changeset/base/198726

Log:
  MFC r198472
    Eliminate an unnecessary check from vm_fault_prefault().

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/vm/vm_fault.c

Modified: stable/8/sys/vm/vm_fault.c
==============================================================================
--- stable/8/sys/vm/vm_fault.c	Sat Oct 31 18:04:34 2009	(r198725)
+++ stable/8/sys/vm/vm_fault.c	Sat Oct 31 18:18:32 2009	(r198726)
@@ -1011,8 +1011,8 @@ vm_fault_prefault(pmap_t pmap, vm_offset
 		while ((m = vm_page_lookup(lobject, pindex)) == NULL &&
 		    lobject->type == OBJT_DEFAULT &&
 		    (backing_object = lobject->backing_object) != NULL) {
-			if (lobject->backing_object_offset & PAGE_MASK)
-				break;
+			KASSERT((lobject->backing_object_offset & PAGE_MASK) ==
+			    0, ("vm_fault_prefault: unaligned object offset"));
 			pindex += lobject->backing_object_offset >> PAGE_SHIFT;
 			VM_OBJECT_LOCK(backing_object);
 			VM_OBJECT_UNLOCK(lobject);

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 18:46:55 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D2CDC106566C;
	Sat, 31 Oct 2009 18:46:55 +0000 (UTC) (envelope-from alc@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C0D5E8FC1B;
	Sat, 31 Oct 2009 18:46:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VIktq3099389;
	Sat, 31 Oct 2009 18:46:55 GMT (envelope-from alc@svn.freebsd.org)
Received: (from alc@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VIktFP099387;
	Sat, 31 Oct 2009 18:46:55 GMT (envelope-from alc@svn.freebsd.org)
Message-Id: <200910311846.n9VIktFP099387@svn.freebsd.org>
From: Alan Cox 
Date: Sat, 31 Oct 2009 18:46:55 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
X-SVN-Group: stable-7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198727 - in stable/7/sys: . contrib/pf vm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 18:46:55 -0000

Author: alc
Date: Sat Oct 31 18:46:55 2009
New Revision: 198727
URL: http://svn.freebsd.org/changeset/base/198727

Log:
  MFC r198472
    Eliminate an unnecessary check from vm_fault_prefault().

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/vm/vm_fault.c

Modified: stable/7/sys/vm/vm_fault.c
==============================================================================
--- stable/7/sys/vm/vm_fault.c	Sat Oct 31 18:18:32 2009	(r198726)
+++ stable/7/sys/vm/vm_fault.c	Sat Oct 31 18:46:55 2009	(r198727)
@@ -970,8 +970,8 @@ vm_fault_prefault(pmap_t pmap, vm_offset
 		while ((m = vm_page_lookup(lobject, pindex)) == NULL &&
 		    lobject->type == OBJT_DEFAULT &&
 		    (backing_object = lobject->backing_object) != NULL) {
-			if (lobject->backing_object_offset & PAGE_MASK)
-				break;
+			KASSERT((lobject->backing_object_offset & PAGE_MASK) ==
+			    0, ("vm_fault_prefault: unaligned object offset"));
 			pindex += lobject->backing_object_offset >> PAGE_SHIFT;
 			VM_OBJECT_LOCK(backing_object);
 			VM_OBJECT_UNLOCK(lobject);

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 18:54:27 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 46897106566C;
	Sat, 31 Oct 2009 18:54:27 +0000 (UTC) (envelope-from alc@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F0B748FC1C;
	Sat, 31 Oct 2009 18:54:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VIsQ2G099601;
	Sat, 31 Oct 2009 18:54:26 GMT (envelope-from alc@svn.freebsd.org)
Received: (from alc@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VIsQYQ099590;
	Sat, 31 Oct 2009 18:54:26 GMT (envelope-from alc@svn.freebsd.org)
Message-Id: <200910311854.n9VIsQYQ099590@svn.freebsd.org>
From: Alan Cox 
Date: Sat, 31 Oct 2009 18:54:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198728 - in stable/8/sys: . amd64/include
	amd64/include/xen arm/include cddl/contrib/opensolaris
	contrib/dev/acpica contrib/pf dev/xen/xenpci i386/include
	ia64/include kern mips/includ...
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 18:54:27 -0000

Author: alc
Date: Sat Oct 31 18:54:26 2009
New Revision: 198728
URL: http://svn.freebsd.org/changeset/base/198728

Log:
  MFC r197316
    Add a new sysctl for reporting all of the supported page sizes.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/param.h
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/arm/include/param.h
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/i386/include/param.h
  stable/8/sys/ia64/include/param.h
  stable/8/sys/kern/kern_mib.c
  stable/8/sys/mips/include/param.h
  stable/8/sys/powerpc/include/param.h
  stable/8/sys/sparc64/include/param.h
  stable/8/sys/sun4v/include/param.h
  stable/8/sys/sys/systm.h

Modified: stable/8/sys/amd64/include/param.h
==============================================================================
--- stable/8/sys/amd64/include/param.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/amd64/include/param.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -118,6 +118,8 @@
 #define	NBPML4		(1ul<flags & SCTL_MASK32) {
+		/*
+		 * Recreate the "pagesizes" array with 32-bit elements.  Truncate
+		 * any page size greater than UINT32_MAX to zero.
+		 */
+		for (i = 0; i < MAXPAGESIZES; i++)
+			pagesizes32[i] = (uint32_t)pagesizes[i];
+
+		error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32));
+	} else
+#endif
+		error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes));
+	return (error);
+}
+SYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD,
+    NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes");
+
 static char	machine_arch[] = MACHINE_ARCH;
 SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
     machine_arch, 0, "System architecture");

Modified: stable/8/sys/mips/include/param.h
==============================================================================
--- stable/8/sys/mips/include/param.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/mips/include/param.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -115,6 +115,8 @@
 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
 #define	SEGSHIFT	22		/* LOG2(NBSEG) */
 
+#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
+
 /* XXXimp: This has moved to vmparam.h */
 /* Also, this differs from the mips2 definition, but likely is better */
 /* since this means the kernel won't chew up TLBs when it is executing */

Modified: stable/8/sys/powerpc/include/param.h
==============================================================================
--- stable/8/sys/powerpc/include/param.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/powerpc/include/param.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -98,6 +98,8 @@
 #define	PAGE_MASK	(PAGE_SIZE - 1)
 #define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
 
+#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
+
 #ifndef KSTACK_PAGES
 #define	KSTACK_PAGES		4		/* includes pcb */
 #endif

Modified: stable/8/sys/sparc64/include/param.h
==============================================================================
--- stable/8/sys/sparc64/include/param.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/sparc64/include/param.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -121,6 +121,8 @@
 #define PAGE_SIZE_MAX	PAGE_SIZE_4M
 #define PAGE_MASK_MAX	PAGE_MASK_4M
 
+#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
+
 #ifndef KSTACK_PAGES
 #define KSTACK_PAGES		4	/* pages of kernel stack (with pcb) */
 #endif

Modified: stable/8/sys/sun4v/include/param.h
==============================================================================
--- stable/8/sys/sun4v/include/param.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/sun4v/include/param.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -116,6 +116,8 @@
 #define PAGE_SIZE_MAX	PAGE_SIZE_4M
 #define PAGE_MASK_MAX	PAGE_MASK_4M
 
+#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
+
 #ifndef KSTACK_PAGES
 #define KSTACK_PAGES		4	/* pages of kernel stack (with pcb) */
 #endif

Modified: stable/8/sys/sys/systm.h
==============================================================================
--- stable/8/sys/sys/systm.h	Sat Oct 31 18:46:55 2009	(r198727)
+++ stable/8/sys/sys/systm.h	Sat Oct 31 18:54:26 2009	(r198728)
@@ -54,6 +54,7 @@ extern int kstack_pages;	/* number of ke
 
 extern int nswap;		/* size of swap space */
 
+extern u_long pagesizes[];	/* supported page sizes */
 extern long physmem;		/* physical memory */
 extern long realmem;		/* 'real' memory */
 

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 19:02:09 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15FE3106566C;
	Sat, 31 Oct 2009 19:02:09 +0000 (UTC) (envelope-from alc@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 02A078FC1A;
	Sat, 31 Oct 2009 19:02:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VJ28Qr099934;
	Sat, 31 Oct 2009 19:02:08 GMT (envelope-from alc@svn.freebsd.org)
Received: (from alc@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VJ28Zh099931;
	Sat, 31 Oct 2009 19:02:08 GMT (envelope-from alc@svn.freebsd.org)
Message-Id: <200910311902.n9VJ28Zh099931@svn.freebsd.org>
From: Alan Cox 
Date: Sat, 31 Oct 2009 19:02:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198729 - in stable/8/sys: . amd64/amd64
	amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica
	contrib/pf dev/xen/xenpci i386/i386
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 19:02:09 -0000

Author: alc
Date: Sat Oct 31 19:02:08 2009
New Revision: 198729
URL: http://svn.freebsd.org/changeset/base/198729

Log:
  MFC r197317
    When superpages are enabled, add the 2 or 4MB page size to the array of
    supported page sizes.

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/amd64/pmap.c
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/i386/i386/pmap.c

Modified: stable/8/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/8/sys/amd64/amd64/pmap.c	Sat Oct 31 18:54:26 2009	(r198728)
+++ stable/8/sys/amd64/amd64/pmap.c	Sat Oct 31 19:02:08 2009	(r198729)
@@ -663,6 +663,11 @@ pmap_init(void)
 	 * Are large page mappings enabled?
 	 */
 	TUNABLE_INT_FETCH("vm.pmap.pg_ps_enabled", &pg_ps_enabled);
+	if (pg_ps_enabled) {
+		KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0,
+		    ("pmap_init: can't assign to pagesizes[1]"));
+		pagesizes[1] = NBPDR;
+	}
 
 	/*
 	 * Calculate the size of the pv head table for superpages.

Modified: stable/8/sys/i386/i386/pmap.c
==============================================================================
--- stable/8/sys/i386/i386/pmap.c	Sat Oct 31 18:54:26 2009	(r198728)
+++ stable/8/sys/i386/i386/pmap.c	Sat Oct 31 19:02:08 2009	(r198729)
@@ -673,6 +673,11 @@ pmap_init(void)
 	 * Are large page mappings enabled?
 	 */
 	TUNABLE_INT_FETCH("vm.pmap.pg_ps_enabled", &pg_ps_enabled);
+	if (pg_ps_enabled) {
+		KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0,
+		    ("pmap_init: can't assign to pagesizes[1]"));
+		pagesizes[1] = NBPDR;
+	}
 
 	/*
 	 * Calculate the size of the pv head table for superpages.

From owner-svn-src-stable@FreeBSD.ORG  Sat Oct 31 21:22:18 2009
Return-Path: 
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 93BF71065670;
	Sat, 31 Oct 2009 21:22:18 +0000 (UTC)
	(envelope-from sson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7F5418FC15;
	Sat, 31 Oct 2009 21:22:18 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VLMIB8003471;
	Sat, 31 Oct 2009 21:22:18 GMT (envelope-from sson@svn.freebsd.org)
Received: (from sson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VLMIPr003467;
	Sat, 31 Oct 2009 21:22:18 GMT (envelope-from sson@svn.freebsd.org)
Message-Id: <200910312122.n9VLMIPr003467@svn.freebsd.org>
From: Stacey Son 
Date: Sat, 31 Oct 2009 21:22:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r198732 - in stable/8: lib/libc lib/libc/gen
	lib/libc/stdio lib/libc/stdtime lib/libc/string lib/libc/sys
	sys sys/amd64/include/xen sys/cddl/contrib/opensolaris
	sys/contrib/dev/acpica s...
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 31 Oct 2009 21:22:18 -0000

Author: sson
Date: Sat Oct 31 21:22:18 2009
New Revision: 198732
URL: http://svn.freebsd.org/changeset/base/198732

Log:
  MFC 197240,197241,197242,197243,197293,197294,197407:
  
  Add EVFILT_USER filter and EV_DISPATCH/EV_RECEIPT flags to kevent(2).
  
  Approved by: rwatson (mentor)

Modified:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/gen/   (props changed)
  stable/8/lib/libc/stdio/asprintf.c   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/string/ffsll.c   (props changed)
  stable/8/lib/libc/string/flsll.c   (props changed)
  stable/8/lib/libc/string/wcpcpy.c   (props changed)
  stable/8/lib/libc/string/wcpncpy.c   (props changed)
  stable/8/lib/libc/sys/kqueue.2
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/kern_event.c
  stable/8/sys/sys/event.h

Modified: stable/8/lib/libc/sys/kqueue.2
==============================================================================
--- stable/8/lib/libc/sys/kqueue.2	Sat Oct 31 20:59:13 2009	(r198731)
+++ stable/8/lib/libc/sys/kqueue.2	Sat Oct 31 21:22:18 2009	(r198732)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 6, 2007
+.Dd September 15, 2009
 .Dt KQUEUE 2
 .Os
 .Sh NAME
@@ -201,11 +201,25 @@ Disable the event so
 .Fn kevent
 will not return it.
 The filter itself is not disabled.
+.It EV_DISPATCH
+Disable the event source immediately after delivery of an event.
+See 
+.Dv EV_DISABLE
+above.
 .It EV_DELETE
 Removes the event from the kqueue.
 Events which are attached to
 file descriptors are automatically deleted on the last close of
 the descriptor.
+.It EV_RECEIPT
+This flag is useful for making bulk changes to a kqueue without draining
+any pending events.
+When passed as input, it forces
+.Dv EV_ERROR
+to always be returned.
+When a filter is successfully added the 
+.Va data
+field will be zero.
 .It EV_ONESHOT
 Causes the event to return only the first occurrence of the filter
 being triggered.
@@ -441,6 +455,44 @@ The link state is invalid.
 On return,
 .Va fflags
 contains the events which triggered the filter.
+.It Dv EVFILT_USER
+Establishes a user event identified by
+.Va ident
+which is not assosicated with any kernel mechanism but is triggered by
+user level code.
+The lower 24 bits of the 
+.Va fflags
+may be used for user defined flags and manipulated using the following:
+.Bl -tag -width XXNOTE_FFLAGSMASK 
+.It Dv NOTE_FFNOP
+Ignore the input
+.Va fflags .
+.It Dv NOTE_FFAND
+Bitwise AND
+.Va fflags .
+.It Dv NOTE_FFOR
+Bitwise OR
+.Va fflags .
+.It Dv NOTE_COPY
+Copy
+.Va fflags .
+.It Dv NOTE_FFCTRLMASK
+Control mask for
+.Va fflags .
+.It Dv NOTE_FFLAGSMASK
+User defined flag mask for
+.Va fflags .
+.El
+.Pp
+A user event is triggered for output with the following:
+.Bl -tag -width XXNOTE_FFLAGSMASK
+.It Dv NOTE_TRIGGER
+Cause the event to be triggered.
+.El
+.Pp
+On return,
+.Va fflags
+contains the users defined flags in the lower 24 bits.
 .El
 .Sh RETURN VALUES
 The

Modified: stable/8/sys/kern/kern_event.c
==============================================================================
--- stable/8/sys/kern/kern_event.c	Sat Oct 31 20:59:13 2009	(r198731)
+++ stable/8/sys/kern/kern_event.c	Sat Oct 31 21:22:18 2009	(r198732)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
  * Copyright 2004 John-Mark Gurney 
+ * Copyright (c) 2009 Apple, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -141,6 +142,11 @@ static void	filt_timerexpire(void *knx);
 static int	filt_timerattach(struct knote *kn);
 static void	filt_timerdetach(struct knote *kn);
 static int	filt_timer(struct knote *kn, long hint);
+static int	filt_userattach(struct knote *kn);
+static void	filt_userdetach(struct knote *kn);
+static int	filt_user(struct knote *kn, long hint);
+static void	filt_usertouch(struct knote *kn, struct kevent *kev,
+		    u_long type);
 
 static struct filterops file_filtops =
 	{ 1, filt_fileattach, NULL, NULL };
@@ -151,6 +157,12 @@ static struct filterops proc_filtops =
 	{ 0, filt_procattach, filt_procdetach, filt_proc };
 static struct filterops timer_filtops =
 	{ 0, filt_timerattach, filt_timerdetach, filt_timer };
+static struct filterops user_filtops = {
+	.f_attach = filt_userattach,
+	.f_detach = filt_userdetach,
+	.f_event = filt_user,
+	.f_touch = filt_usertouch,
+};
 
 static uma_zone_t	knote_zone;
 static int 		kq_ncallouts = 0;
@@ -255,6 +267,7 @@ static struct {
 	{ &file_filtops },			/* EVFILT_NETDEV */
 	{ &fs_filtops },			/* EVFILT_FS */
 	{ &null_filtops },			/* EVFILT_LIO */
+	{ &user_filtops },			/* EVFILT_USER */
 };
 
 /*
@@ -557,6 +570,94 @@ filt_timer(struct knote *kn, long hint)
 	return (kn->kn_data != 0);
 }
 
+static int
+filt_userattach(struct knote *kn)
+{
+
+	/* 
+	 * EVFILT_USER knotes are not attached to anything in the kernel.
+	 */ 
+	kn->kn_hook = NULL;
+	if (kn->kn_fflags & NOTE_TRIGGER)
+		kn->kn_hookid = 1;
+	else
+		kn->kn_hookid = 0;
+	return (0);
+}
+
+static void
+filt_userdetach(__unused struct knote *kn)
+{
+
+	/*
+	 * EVFILT_USER knotes are not attached to anything in the kernel.
+	 */
+}
+
+static int
+filt_user(struct knote *kn, __unused long hint)
+{
+
+	return (kn->kn_hookid);
+}
+
+static void
+filt_usertouch(struct knote *kn, struct kevent *kev, u_long type)
+{
+	u_int ffctrl;
+
+	switch (type) {
+	case EVENT_REGISTER:
+		if (kev->fflags & NOTE_TRIGGER)
+			kn->kn_hookid = 1;
+
+		ffctrl = kev->fflags & NOTE_FFCTRLMASK;
+		kev->fflags &= NOTE_FFLAGSMASK;
+		switch (ffctrl) {
+		case NOTE_FFNOP:
+			break;
+
+		case NOTE_FFAND:
+			kn->kn_sfflags &= kev->fflags;
+			break;
+
+		case NOTE_FFOR:
+			kn->kn_sfflags |= kev->fflags;
+			break;
+
+		case NOTE_FFCOPY:
+			kn->kn_sfflags = kev->fflags;
+			break;
+
+		default:
+			/* XXX Return error? */
+			break;
+		}
+		kn->kn_sdata = kev->data;
+		if (kev->flags & EV_CLEAR) {
+			kn->kn_hookid = 0;
+			kn->kn_data = 0;
+			kn->kn_fflags = 0;
+		}
+		break;
+
+        case EVENT_PROCESS:
+		*kev = kn->kn_kevent;
+		kev->fflags = kn->kn_sfflags;
+		kev->data = kn->kn_sdata;
+		if (kn->kn_flags & EV_CLEAR) {
+			kn->kn_hookid = 0;
+			kn->kn_data = 0;
+			kn->kn_fflags = 0;
+		}
+		break;
+
+	default:
+		panic("filt_usertouch() - invalid type (%ld)", type);
+		break;
+	}
+}
+
 int
 kqueue(struct thread *td, struct kqueue_args *uap)
 {
@@ -717,7 +818,7 @@ kern_kevent(struct thread *td, int fd, i
 				continue;
 			kevp->flags &= ~EV_SYSFLAGS;
 			error = kqueue_register(kq, kevp, td, 1);
-			if (error) {
+			if (error || (kevp->flags & EV_RECEIPT)) {
 				if (nevents != 0) {
 					kevp->flags = EV_ERROR;
 					kevp->data = error;
@@ -919,17 +1020,11 @@ findkn:
 		goto findkn;
 	}
 
-	if (kn == NULL && ((kev->flags & EV_ADD) == 0)) {
-		KQ_UNLOCK(kq);
-		error = ENOENT;
-		goto done;
-	}
-
 	/*
 	 * kn now contains the matching knote, or NULL if no match
 	 */
-	if (kev->flags & EV_ADD) {
-		if (kn == NULL) {
+	if (kn == NULL) {
+		if (kev->flags & EV_ADD) {
 			kn = tkn;
 			tkn = NULL;
 			if (kn == NULL) {
@@ -968,34 +1063,16 @@ findkn:
 				goto done;
 			}
 			KN_LIST_LOCK(kn);
+			goto done_ev_add;
 		} else {
-			/*
-			 * The user may change some filter values after the
-			 * initial EV_ADD, but doing so will not reset any
-			 * filter which has already been triggered.
-			 */
-			kn->kn_status |= KN_INFLUX;
+			/* No matching knote and the EV_ADD flag is not set. */
 			KQ_UNLOCK(kq);
-			KN_LIST_LOCK(kn);
-			kn->kn_sfflags = kev->fflags;
-			kn->kn_sdata = kev->data;
-			kn->kn_kevent.udata = kev->udata;
+			error = ENOENT;
+			goto done;
 		}
-
-		/*
-		 * We can get here with kn->kn_knlist == NULL.
-		 * This can happen when the initial attach event decides that
-		 * the event is "completed" already.  i.e. filt_procattach
-		 * is called on a zombie process.  It will call filt_proc
-		 * which will remove it from the list, and NULL kn_knlist.
-		 */
-		event = kn->kn_fop->f_event(kn, 0);
-		KQ_LOCK(kq);
-		if (event)
-			KNOTE_ACTIVATE(kn, 1);
-		kn->kn_status &= ~KN_INFLUX;
-		KN_LIST_UNLOCK(kn);
-	} else if (kev->flags & EV_DELETE) {
+	}
+	
+	if (kev->flags & EV_DELETE) {
 		kn->kn_status |= KN_INFLUX;
 		KQ_UNLOCK(kq);
 		if (!(kn->kn_status & KN_DETACHED))
@@ -1004,6 +1081,37 @@ findkn:
 		goto done;
 	}
 
+	/*
+	 * The user may change some filter values after the initial EV_ADD,
+	 * but doing so will not reset any filter which has already been
+	 * triggered.
+	 */
+	kn->kn_status |= KN_INFLUX;
+	KQ_UNLOCK(kq);
+	KN_LIST_LOCK(kn);
+	kn->kn_kevent.udata = kev->udata;
+	if (!fops->f_isfd && fops->f_touch != NULL) {
+		fops->f_touch(kn, kev, EVENT_REGISTER);
+	} else {
+		kn->kn_sfflags = kev->fflags;
+		kn->kn_sdata = kev->data;
+	}
+
+	/*
+	 * We can get here with kn->kn_knlist == NULL.  This can happen when
+	 * the initial attach event decides that the event is "completed" 
+	 * already.  i.e. filt_procattach is called on a zombie process.  It
+	 * will call filt_proc which will remove it from the list, and NULL
+	 * kn_knlist.
+	 */
+done_ev_add:
+	event = kn->kn_fop->f_event(kn, 0);
+	KQ_LOCK(kq);
+	if (event)
+		KNOTE_ACTIVATE(kn, 1);
+	kn->kn_status &= ~KN_INFLUX;
+	KN_LIST_UNLOCK(kn);
+
 	if ((kev->flags & EV_DISABLE) &&
 	    ((kn->kn_status & KN_DISABLED) == 0)) {
 		kn->kn_status |= KN_DISABLED;
@@ -1183,7 +1291,7 @@ kqueue_scan(struct kqueue *kq, int maxev
 	struct timeval atv, rtv, ttv;
 	struct knote *kn, *marker;
 	int count, timeout, nkev, error, influx;
-	int haskqglobal;
+	int haskqglobal, touch;
 
 	count = maxevents;
 	nkev = 0;
@@ -1315,12 +1423,25 @@ start:
 				influx = 1;
 				continue;
 			}
-			*kevp = kn->kn_kevent;
+			touch = (!kn->kn_fop->f_isfd &&
+			    kn->kn_fop->f_touch != NULL);
+			if (touch)
+				kn->kn_fop->f_touch(kn, kevp, EVENT_PROCESS);
+			else
+				*kevp = kn->kn_kevent;
 			KQ_LOCK(kq);
 			KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal);
-			if (kn->kn_flags & EV_CLEAR) {
-				kn->kn_data = 0;
-				kn->kn_fflags = 0;
+			if (kn->kn_flags & (EV_CLEAR |  EV_DISPATCH)) {
+				/* 
+				 * Manually clear knotes who weren't 
+				 * 'touch'ed.
+				 */
+				if (touch == 0 && kn->kn_flags & EV_CLEAR) {
+					kn->kn_data = 0;
+					kn->kn_fflags = 0;
+				}
+				if (kn->kn_flags & EV_DISPATCH)
+					kn->kn_status |= KN_DISABLED;
 				kn->kn_status &= ~(KN_QUEUED | KN_ACTIVE);
 				kq->kq_count--;
 			} else

Modified: stable/8/sys/sys/event.h
==============================================================================
--- stable/8/sys/sys/event.h	Sat Oct 31 20:59:13 2009	(r198731)
+++ stable/8/sys/sys/event.h	Sat Oct 31 21:22:18 2009	(r198732)
@@ -41,7 +41,8 @@
 #define EVFILT_NETDEV		(-8)	/* network devices */
 #define EVFILT_FS		(-9)	/* filesystem events */
 #define EVFILT_LIO		(-10)	/* attached to lio requests */
-#define EVFILT_SYSCOUNT		10
+#define EVFILT_USER		(-11)	/* User events */
+#define EVFILT_SYSCOUNT		11
 
 #define EV_SET(kevp_, a, b, c, d, e, f) do {	\
 	struct kevent *kevp = (kevp_);		\
@@ -71,6 +72,8 @@ struct kevent {
 /* flags */
 #define EV_ONESHOT	0x0010		/* only report one occurrence */
 #define EV_CLEAR	0x0020		/* clear event state after reporting */
+#define EV_RECEIPT	0x0040		/* force EV_ERROR on success, data=0 */
+#define EV_DISPATCH	0x0080		/* disable event after reporting */
 
 #define EV_SYSFLAGS	0xF000		/* reserved by system */
 #define EV_FLAG1	0x2000		/* filter-specific flag */
@@ -79,6 +82,25 @@ struct kevent {
 #define EV_EOF		0x8000		/* EOF detected */
 #define EV_ERROR	0x4000		/* error, data contains errno */
 
+ /*
+  * data/hint flags/masks for EVFILT_USER, shared with userspace
+  *
+  * On input, the top two bits of fflags specifies how the lower twenty four
+  * bits should be applied to the stored value of fflags.
+  *
+  * On output, the top two bits will always be set to NOTE_FFNOP and the
+  * remaining twenty four bits will contain the stored fflags value.
+  */
+#define NOTE_FFNOP	0x00000000		/* ignore input fflags */
+#define NOTE_FFAND	0x40000000		/* AND fflags */
+#define NOTE_FFOR	0x80000000		/* OR fflags */
+#define NOTE_FFCOPY	0xc0000000		/* copy fflags */
+#define NOTE_FFCTRLMASK	0xc0000000		/* masks for operations */
+#define NOTE_FFLAGSMASK	0x00ffffff
+
+#define NOTE_TRIGGER	0x01000000		/* Cause the event to be
+						   triggered for output. */
+
 /*
  * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
  */
@@ -154,11 +176,22 @@ MALLOC_DECLARE(M_KQUEUE);
  */
 #define NOTE_SIGNAL	0x08000000
 
+/*
+ * Hint values for the optional f_touch event filter.  If f_touch is not set 
+ * to NULL and f_isfd is zero the f_touch filter will be called with the type
+ * argument set to EVENT_REGISTER during a kevent() system call.  It is also
+ * called under the same conditions with the type argument set to EVENT_PROCESS
+ * when the event has been triggered.
+ */
+#define EVENT_REGISTER	1
+#define EVENT_PROCESS	2
+
 struct filterops {
 	int	f_isfd;		/* true if ident == filedescriptor */
 	int	(*f_attach)(struct knote *kn);
 	void	(*f_detach)(struct knote *kn);
 	int	(*f_event)(struct knote *kn, long hint);
+	void	(*f_touch)(struct knote *kn, struct kevent *kev, u_long type);
 };
 
 /*
@@ -193,6 +226,7 @@ struct knote {
 	} kn_ptr;
 	struct			filterops *kn_fop;
 	void			*kn_hook;
+	int			kn_hookid;
 
 #define kn_id		kn_kevent.ident
 #define kn_filter	kn_kevent.filter