From owner-svn-src-stable-7@FreeBSD.ORG Sun May 3 17:51:38 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5D181065672; Sun, 3 May 2009 17:51:38 +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 78CCA8FC25; Sun, 3 May 2009 17:51:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n43Hpcdr020176; Sun, 3 May 2009 17:51:38 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n43HpcGV020175; Sun, 3 May 2009 17:51:38 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200905031751.n43HpcGV020175@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 3 May 2009 17:51: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: r191767 - in stable/7/lib/libc: . stdlib string X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2009 17:51:39 -0000 Author: kib Date: Sun May 3 17:51:38 2009 New Revision: 191767 URL: http://svn.freebsd.org/changeset/base/191767 Log: MFC r185514 (by jasone): Fix a lock order reversal bug that could cause deadlock during fork(2). Reported and tested by: makc Approved by: re (kensmith) Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdlib/malloc.c stable/7/lib/libc/string/ffsll.c (props changed) stable/7/lib/libc/string/flsll.c (props changed) Modified: stable/7/lib/libc/stdlib/malloc.c ============================================================================== --- stable/7/lib/libc/stdlib/malloc.c Sun May 3 17:47:21 2009 (r191766) +++ stable/7/lib/libc/stdlib/malloc.c Sun May 3 17:51:38 2009 (r191767) @@ -4715,16 +4715,41 @@ _malloc_thread_cleanup(void) void _malloc_prefork(void) { - unsigned i; + bool again; + unsigned i, j; + arena_t *larenas[narenas], *tarenas[narenas]; /* Acquire all mutexes in a safe order. */ - malloc_spin_lock(&arenas_lock); - for (i = 0; i < narenas; i++) { - if (arenas[i] != NULL) - malloc_spin_lock(&arenas[i]->lock); - } - malloc_spin_unlock(&arenas_lock); + /* + * arenas_lock must be acquired after all of the arena mutexes, in + * order to avoid potential deadlock with arena_lock_balance[_hard](). + * Since arenas_lock protects the arenas array, the following code has + * to race with arenas_extend() callers until it succeeds in locking + * all arenas before locking arenas_lock. + */ + memset(larenas, 0, sizeof(arena_t *) * narenas); + do { + again = false; + + malloc_spin_lock(&arenas_lock); + for (i = 0; i < narenas; i++) { + if (arenas[i] != larenas[i]) { + memcpy(tarenas, arenas, sizeof(arena_t *) * + narenas); + malloc_spin_unlock(&arenas_lock); + for (j = 0; j < narenas; j++) { + if (larenas[j] != tarenas[j]) { + larenas[j] = tarenas[j]; + malloc_spin_lock( + &larenas[j]->lock); + } + } + again = true; + break; + } + } + } while (again); malloc_mutex_lock(&base_mtx); @@ -4739,6 +4764,7 @@ void _malloc_postfork(void) { unsigned i; + arena_t *larenas[narenas]; /* Release all mutexes, now that fork() has completed. */ @@ -4750,12 +4776,12 @@ _malloc_postfork(void) malloc_mutex_unlock(&base_mtx); - malloc_spin_lock(&arenas_lock); + memcpy(larenas, arenas, sizeof(arena_t *) * narenas); + malloc_spin_unlock(&arenas_lock); for (i = 0; i < narenas; i++) { - if (arenas[i] != NULL) - malloc_spin_unlock(&arenas[i]->lock); + if (larenas[i] != NULL) + malloc_spin_unlock(&larenas[i]->lock); } - malloc_spin_unlock(&arenas_lock); } /* From owner-svn-src-stable-7@FreeBSD.ORG Sun May 3 18:22:08 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16985106566B; Sun, 3 May 2009 18:22:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id A97D78FC23; Sun, 3 May 2009 18:22:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1M0fuE-000Nfh-P4; Sun, 03 May 2009 20:55:14 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n43Ht6F6053368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 3 May 2009 20:55:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n43Ht6FF076882; Sun, 3 May 2009 20:55:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n43Ht67n076881; Sun, 3 May 2009 20:55:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 3 May 2009 20:55:06 +0300 From: Kostik Belousov To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Message-ID: <20090503175506.GM17826@deviant.kiev.zoral.com.ua> References: <200905031751.n43HpcGV020175@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WuedheRyq6FDfQ9j" Content-Disposition: inline In-Reply-To: <200905031751.n43HpcGV020175@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1M0fuE-000Nfh-P4 cd440303ab753cda8a13d631c6d6e8ef X-Terabit: YES Cc: Subject: Re: svn commit: r191767 - in stable/7/lib/libc: . stdlib string X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2009 18:22:08 -0000 --WuedheRyq6FDfQ9j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 03, 2009 at 05:51:38PM +0000, Konstantin Belousov wrote: > Author: kib > Date: Sun May 3 17:51:38 2009 > New Revision: 191767 > URL: http://svn.freebsd.org/changeset/base/191767 >=20 > Log: > MFC r185514 (by jasone): > Fix a lock order reversal bug that could cause deadlock during fork(2). > =20 > Reported and tested by: makc > Approved by: re (kensmith) It was diagnosed and tested after the 7.2 release passed the point of no return. We expect to issue errata notice after the patch settles in stable/7 shortly. --WuedheRyq6FDfQ9j Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkn92noACgkQC3+MBN1Mb4hZogCfdu/pt4/+3WN5aLIhh8m2oktj Oi4AoLMypMwAX7TXvsPZjaERVYonNVoV =J+l2 -----END PGP SIGNATURE----- --WuedheRyq6FDfQ9j-- From owner-svn-src-stable-7@FreeBSD.ORG Sun May 3 21:21:17 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 870DB1065676; Sun, 3 May 2009 21:21:17 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 748768FC16; Sun, 3 May 2009 21:21:17 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n43LLHZZ024825; Sun, 3 May 2009 21:21:17 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n43LLHif024824; Sun, 3 May 2009 21:21:17 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <200905032121.n43LLHif024824@svn.freebsd.org> From: Hiroki Sato Date: Sun, 3 May 2009 21:21:17 +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: r191769 - stable/7/release/doc/en_US.ISO8859-1/errata X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2009 21:21:18 -0000 Author: hrs Date: Sun May 3 21:21:17 2009 New Revision: 191769 URL: http://svn.freebsd.org/changeset/base/191769 Log: Add an entry for a lock order reversal that can cause a deadlock. Reviewed by: kib Approved by: re (implicit) Modified: stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Modified: stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Sun May 3 18:29:04 2009 (r191768) +++ stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Sun May 3 21:21:17 2009 (r191769) @@ -169,6 +169,14 @@ workaround, you can boot using the bootonly or livefs CDROM and then swap in disc1 once sysinstall starts. + [20090504] A lock handling error has been found in + interaction between &man.malloc.3; implementation and threading + library. When a multi-threaded process calls the &man.fork.2; + system call in a thread and the &man.malloc.3; function in + another thread, it can cause a deadlock in the child process. + An Errata Notice to fix this problem is planned for this problem + after the release. + Late-Breaking News and Corrections From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 00:19:01 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0805F10657AF; Mon, 4 May 2009 00:19: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 E9B768FC18; Mon, 4 May 2009 00:19:00 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n440J06k028260; Mon, 4 May 2009 00:19:00 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n440J0JZ028259; Mon, 4 May 2009 00:19:00 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <200905040019.n440J0JZ028259@svn.freebsd.org> From: Ken Smith Date: Mon, 4 May 2009 00:19:00 +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: r191770 - stable/7/sys/conf X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 00:19:01 -0000 Author: kensmith Date: Mon May 4 00:19:00 2009 New Revision: 191770 URL: http://svn.freebsd.org/changeset/base/191770 Log: 7.2-RELEASE is done, shift over to -STABLE. Approved by: re (implicit) Modified: stable/7/sys/conf/newvers.sh Modified: stable/7/sys/conf/newvers.sh ============================================================================== --- stable/7/sys/conf/newvers.sh Sun May 3 21:21:17 2009 (r191769) +++ stable/7/sys/conf/newvers.sh Mon May 4 00:19:00 2009 (r191770) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="7.2" -BRANCH="PRERELEASE" +BRANCH="STABLE" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 10:15:34 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F87C106566B; Mon, 4 May 2009 10:15:34 +0000 (UTC) (envelope-from rink@rink.nu) Received: from mx1.rink.nu (gloom.rink.nu [213.34.49.2]) by mx1.freebsd.org (Postfix) with ESMTP id 5D9708FC17; Mon, 4 May 2009 10:15:34 +0000 (UTC) (envelope-from rink@rink.nu) Received: from localhost (localhost [127.0.0.1]) by mx1.rink.nu (Postfix) with ESMTP id 337806D43C; Mon, 4 May 2009 11:58:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at rink.nu Received: from mx1.rink.nu ([213.34.49.2]) by localhost (gloom.rink.nu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EV4XX790Pxf9; Mon, 4 May 2009 11:58:06 +0200 (CEST) Received: by mx1.rink.nu (Postfix, from userid 1000) id A5D7B6D43B; Mon, 4 May 2009 11:58:06 +0200 (CEST) Date: Mon, 4 May 2009 11:58:06 +0200 From: Rink Springer To: Kostik Belousov Message-ID: <20090504095806.GD78380@rink.nu> References: <200905031751.n43HpcGV020175@svn.freebsd.org> <20090503175506.GM17826@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090503175506.GM17826@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.18 (2008-05-17) 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: r191767 - in stable/7/lib/libc: . stdlib string X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 10:15:35 -0000 On Sun, May 03, 2009 at 08:55:06PM +0300, Kostik Belousov wrote: > On Sun, May 03, 2009 at 05:51:38PM +0000, Konstantin Belousov wrote: > > Author: kib > > Date: Sun May 3 17:51:38 2009 > > New Revision: 191767 > > URL: http://svn.freebsd.org/changeset/base/191767 > > > > Log: > > MFC r185514 (by jasone): > > Fix a lock order reversal bug that could cause deadlock during fork(2). > > > > Reported and tested by: makc > > Approved by: re (kensmith) > > It was diagnosed and tested after the 7.2 release passed the point of > no return. We expect to issue errata notice after the patch settles > in stable/7 shortly. Is this the same malloc/fork deadlock bug bug I reported about 6 months ago? -- Rink P.W. Springer - http://rink.nu "Talk to me." - Horatio Caine From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 11:39:02 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FE891065670; Mon, 4 May 2009 11:39:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 2B4818FC21; Mon, 4 May 2009 11:39:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1M0wVf-000COW-Ti; Mon, 04 May 2009 14:39:00 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n44Bcpo4021071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 May 2009 14:38:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n44Bcpet058367; Mon, 4 May 2009 14:38:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n44Bcpa8058362; Mon, 4 May 2009 14:38:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 4 May 2009 14:38:51 +0300 From: Kostik Belousov To: Rink Springer Message-ID: <20090504113851.GA1948@deviant.kiev.zoral.com.ua> References: <200905031751.n43HpcGV020175@svn.freebsd.org> <20090503175506.GM17826@deviant.kiev.zoral.com.ua> <20090504095806.GD78380@rink.nu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OgqxwSJOaUobr8KG" Content-Disposition: inline In-Reply-To: <20090504095806.GD78380@rink.nu> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1M0wVf-000COW-Ti dcdf07f5b9e53ae2adacb8e0463b0def X-Terabit: YES 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: r191767 - in stable/7/lib/libc: . stdlib string X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 11:39:03 -0000 --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 04, 2009 at 11:58:06AM +0200, Rink Springer wrote: > On Sun, May 03, 2009 at 08:55:06PM +0300, Kostik Belousov wrote: > > On Sun, May 03, 2009 at 05:51:38PM +0000, Konstantin Belousov wrote: > > > Author: kib > > > Date: Sun May 3 17:51:38 2009 > > > New Revision: 191767 > > > URL: http://svn.freebsd.org/changeset/base/191767 > > >=20 > > > Log: > > > MFC r185514 (by jasone): > > > Fix a lock order reversal bug that could cause deadlock during fork= (2). > > > =20 > > > Reported and tested by: makc > > > Approved by: re (kensmith) > >=20 > > It was diagnosed and tested after the 7.2 release passed the point of > > no return. We expect to issue errata notice after the patch settles > > in stable/7 shortly. >=20 > Is this the same malloc/fork deadlock bug bug I reported about 6 months > ago? This was one of the bugs that was fixed after the investigation of your issues. --OgqxwSJOaUobr8KG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkn+08oACgkQC3+MBN1Mb4gFmACfV7nFJ2Scte30XTsCQdy7szxO YPUAoIt7k0JvvkkLVt2bCOsweaDKVoMY =rlVV -----END PGP SIGNATURE----- --OgqxwSJOaUobr8KG-- From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 17:25:53 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B01A106566B; Mon, 4 May 2009 17:25:53 +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 78E9D8FC0A; Mon, 4 May 2009 17:25:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44HPr0l051560; Mon, 4 May 2009 17:25:53 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44HPrft051559; Mon, 4 May 2009 17:25:53 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905041725.n44HPrft051559@svn.freebsd.org> From: John Baldwin Date: Mon, 4 May 2009 17:25: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: r191785 - stable/7/lib/libstand X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 17:25:54 -0000 Author: jhb Date: Mon May 4 17:25:53 2009 New Revision: 191785 URL: http://svn.freebsd.org/changeset/base/191785 Log: MFC: Fix an off-by-one buffer overflow in ngets(). Modified: stable/7/lib/libstand/ (props changed) stable/7/lib/libstand/gets.c Modified: stable/7/lib/libstand/gets.c ============================================================================== --- stable/7/lib/libstand/gets.c Mon May 4 16:10:37 2009 (r191784) +++ stable/7/lib/libstand/gets.c Mon May 4 17:25:53 2009 (r191785) @@ -74,7 +74,7 @@ ngets(char *buf, int n) putchar('\n'); break; default: - if ((n < 1) || ((lp - buf) < n)) { + if ((n < 1) || ((lp - buf) < n - 1)) { *lp++ = c; putchar(c); } From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 18:35:52 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 965E5106566B; Mon, 4 May 2009 18:35:52 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 691778FC19; Mon, 4 May 2009 18:35:52 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44IZqsq053601; Mon, 4 May 2009 18:35:52 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44IZqJS053600; Mon, 4 May 2009 18:35:52 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200905041835.n44IZqJS053600@svn.freebsd.org> From: Ulf Lilleengen Date: Mon, 4 May 2009 18:35: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: r191790 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb geom X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 18:35:53 -0000 Author: lulf Date: Mon May 4 18:35:52 2009 New Revision: 191790 URL: http://svn.freebsd.org/changeset/base/191790 Log: MFC r179094: Play nice with DDB pager. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/geom/geom_subr.c Modified: stable/7/sys/geom/geom_subr.c ============================================================================== --- stable/7/sys/geom/geom_subr.c Mon May 4 18:14:45 2009 (r191789) +++ stable/7/sys/geom/geom_subr.c Mon May 4 18:35:52 2009 (r191790) @@ -1157,8 +1157,11 @@ db_show_geom_provider(int indent, struct printf("\n"); } if (!LIST_EMPTY(&pp->consumers)) { - LIST_FOREACH(cp, &pp->consumers, consumers) + LIST_FOREACH(cp, &pp->consumers, consumers) { db_show_geom_consumer(indent + 2, cp); + if (db_pager_quit) + break; + } } } @@ -1189,12 +1192,18 @@ db_show_geom_geom(int indent, struct g_g printf("\n"); } if (!LIST_EMPTY(&gp->provider)) { - LIST_FOREACH(pp, &gp->provider, provider) + LIST_FOREACH(pp, &gp->provider, provider) { db_show_geom_provider(indent + 2, pp); + if (db_pager_quit) + break; + } } if (!LIST_EMPTY(&gp->consumer)) { - LIST_FOREACH(cp, &gp->consumer, consumer) + LIST_FOREACH(cp, &gp->consumer, consumer) { db_show_geom_consumer(indent + 2, cp); + if (db_pager_quit) + break; + } } } @@ -1204,8 +1213,11 @@ db_show_geom_class(struct g_class *mp) struct g_geom *gp; printf("class: %s (%p)\n", mp->name, mp); - LIST_FOREACH(gp, &mp->geom, geom) + LIST_FOREACH(gp, &mp->geom, geom) { db_show_geom_geom(2, gp); + if (db_pager_quit) + break; + } } /* @@ -1220,6 +1232,8 @@ DB_SHOW_COMMAND(geom, db_show_geom) LIST_FOREACH(mp, &g_classes, class) { db_show_geom_class(mp); printf("\n"); + if (db_pager_quit) + break; } } else { switch (g_valid_obj((void *)addr)) { From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 19:00:26 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 075031065676; Mon, 4 May 2009 19:00:26 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CBCF48FC25; Mon, 4 May 2009 19:00:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44J0PgI054229; Mon, 4 May 2009 19:00:25 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44J0PlF054228; Mon, 4 May 2009 19:00:25 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <200905041900.n44J0PlF054228@svn.freebsd.org> From: Hiroki Sato Date: Mon, 4 May 2009 19:00:25 +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: r191791 - stable/7/release/doc/en_US.ISO8859-1/errata X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 19:00:30 -0000 Author: hrs Date: Mon May 4 19:00:25 2009 New Revision: 191791 URL: http://svn.freebsd.org/changeset/base/191791 Log: Update 7.2R Errata: Document bce(4) + lagg(4) issue, and A patch for lock order reversal committed. Modified: stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Modified: stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Mon May 4 18:35:52 2009 (r191790) +++ stable/7/release/doc/en_US.ISO8859-1/errata/article.sgml Mon May 4 19:00:25 2009 (r191791) @@ -167,19 +167,28 @@ bootable and fall through to booting off the next boot device. All affected machines did see the other discs as bootable. As a workaround, you can boot using the bootonly or livefs CDROM and - then swap in disc1 once sysinstall starts. + then swap in disc1 once &man.sysinstall.8; starts. [20090504] A lock handling error has been found in interaction between &man.malloc.3; implementation and threading library. When a multi-threaded process calls the &man.fork.2; system call in a thread and the &man.malloc.3; function in another thread, it can cause a deadlock in the child process. - An Errata Notice to fix this problem is planned for this problem - after the release. + An Errata Notice to fix this problem is planned after the + release. + + [20090505] A bug was found in the &man.bce.4; driver. This + prevents it from working with the &man.lagg.4; driver in the + LACP (IEEE 802.3ad Link Aggregation Control Protocol) mode. An + Errata Notice to fix this problem is planned after the + release. Late-Breaking News and Corrections - No news. + [20090504] A patch to solve the locking issue in the + &man.malloc.3; implementation and threading library has been + committed to the RELENG_7 branch for public + testing. From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 19:19:14 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23BDC1065670; Mon, 4 May 2009 19:19: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 071C08FC20; Mon, 4 May 2009 19:19:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44JJDgt054689; Mon, 4 May 2009 19:19:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44JJDws054687; Mon, 4 May 2009 19:19:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905041919.n44JJDws054687@svn.freebsd.org> From: John Baldwin Date: Mon, 4 May 2009 19:19: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: r191793 - in stable/7/sys: . amd64/amd64 contrib/pf dev/ath/ath_hal dev/cxgb i386/isa X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 19:19:14 -0000 Author: jhb Date: Mon May 4 19:19:13 2009 New Revision: 191793 URL: http://svn.freebsd.org/changeset/base/191793 Log: MFC: More refinements to the x86 FPU support: - Rename (fpu|npx)_cleanstate to (fpu|npx)_initialstate to better reflect their purpose. - Fix a few nits in the earlier changes to prevent local information leakage in AMD FPUs. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/fpu.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/i386/isa/npx.c Modified: stable/7/sys/amd64/amd64/fpu.c ============================================================================== --- stable/7/sys/amd64/amd64/fpu.c Mon May 4 19:06:05 2009 (r191792) +++ stable/7/sys/amd64/amd64/fpu.c Mon May 4 19:19:13 2009 (r191793) @@ -101,7 +101,7 @@ static void fpu_clean_state(void); SYSCTL_INT(_hw, HW_FLOATINGPT, floatingpoint, CTLFLAG_RD, NULL, 1, "Floating point instructions executed in hardware"); -static struct savefpu fpu_cleanstate; +static struct savefpu fpu_initialstate; /* * Initialize the floating point unit. On the boot CPU we generate a @@ -123,13 +123,13 @@ fpuinit(void) mxcsr = __INITIAL_MXCSR__; ldmxcsr(mxcsr); if (PCPU_GET(cpuid) == 0) { - fxsave(&fpu_cleanstate); - if (fpu_cleanstate.sv_env.en_mxcsr_mask) - cpu_mxcsr_mask = fpu_cleanstate.sv_env.en_mxcsr_mask; + fxsave(&fpu_initialstate); + if (fpu_initialstate.sv_env.en_mxcsr_mask) + cpu_mxcsr_mask = fpu_initialstate.sv_env.en_mxcsr_mask; else cpu_mxcsr_mask = 0xFFBF; - bzero(fpu_cleanstate.sv_fp, sizeof(fpu_cleanstate.sv_fp)); - bzero(fpu_cleanstate.sv_xmm, sizeof(fpu_cleanstate.sv_xmm)); + bzero(fpu_initialstate.sv_fp, sizeof(fpu_initialstate.sv_fp)); + bzero(fpu_initialstate.sv_xmm, sizeof(fpu_initialstate.sv_xmm)); } start_emulating(); intr_restore(savecrit); @@ -416,10 +416,11 @@ fpudna(void) if ((pcb->pcb_flags & PCB_FPUINITDONE) == 0) { /* - * This is the first time this thread has used the FPU, - * explicitly load sanitized registers. + * This is the first time this thread has used the FPU or + * the PCB doesn't contain a clean FPU state. Explicitly + * load an initial state. */ - fxrstor(&fpu_cleanstate); + fxrstor(&fpu_initialstate); if (pcb->pcb_initial_fpucw != __INITIAL_FPUCW__) fldcw(&pcb->pcb_initial_fpucw); pcb->pcb_flags |= PCB_FPUINITDONE; @@ -453,7 +454,7 @@ fpugetregs(struct thread *td, struct sav register_t s; if ((td->td_pcb->pcb_flags & PCB_FPUINITDONE) == 0) { - bcopy(&fpu_cleanstate, addr, sizeof(fpu_cleanstate)); + bcopy(&fpu_initialstate, addr, sizeof(fpu_initialstate)); addr->sv_env.en_cw = td->td_pcb->pcb_initial_fpucw; return (_MC_FPOWNED_NONE); } @@ -479,7 +480,6 @@ fpusetregs(struct thread *td, struct sav s = intr_disable(); if (td == PCPU_GET(fpcurthread)) { - fpu_clean_state(); fxrstor(addr); intr_restore(s); } else { @@ -498,10 +498,10 @@ fpusetregs(struct thread *td, struct sav * In order to avoid leaking this information across processes, we clean * these values by performing a dummy load before executing fxrstor(). */ -static double dummy_variable = 0.0; static void fpu_clean_state(void) { + static float dummy_variable = 0.0; u_short status; /* Modified: stable/7/sys/i386/isa/npx.c ============================================================================== --- stable/7/sys/i386/isa/npx.c Mon May 4 19:06:05 2009 (r191792) +++ stable/7/sys/i386/isa/npx.c Mon May 4 19:19:13 2009 (r191793) @@ -172,7 +172,7 @@ SYSCTL_INT(_hw, HW_FLOATINGPT, floatingp static volatile u_int npx_intrs_while_probing; static volatile u_int npx_traps_while_probing; -static union savefpu npx_cleanstate; +static union savefpu npx_initialstate; static bool_t npx_ex16; static bool_t npx_exists; static bool_t npx_irq13; @@ -414,24 +414,24 @@ npx_attach(dev) s = intr_disable(); stop_emulating(); - fpusave(&npx_cleanstate); + fpusave(&npx_initialstate); start_emulating(); #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - if (npx_cleanstate.sv_xmm.sv_env.en_mxcsr_mask) + if (npx_initialstate.sv_xmm.sv_env.en_mxcsr_mask) cpu_mxcsr_mask = - npx_cleanstate.sv_xmm.sv_env.en_mxcsr_mask; + npx_initialstate.sv_xmm.sv_env.en_mxcsr_mask; else cpu_mxcsr_mask = 0xFFBF; - bzero(npx_cleanstate.sv_xmm.sv_fp, - sizeof(npx_cleanstate.sv_xmm.sv_fp)); - bzero(npx_cleanstate.sv_xmm.sv_xmm, - sizeof(npx_cleanstate.sv_xmm.sv_xmm)); + bzero(npx_initialstate.sv_xmm.sv_fp, + sizeof(npx_initialstate.sv_xmm.sv_fp)); + bzero(npx_initialstate.sv_xmm.sv_xmm, + sizeof(npx_initialstate.sv_xmm.sv_xmm)); /* XXX might need even more zeroing. */ } else #endif - bzero(npx_cleanstate.sv_87.sv_ac, - sizeof(npx_cleanstate.sv_87.sv_ac)); + bzero(npx_initialstate.sv_87.sv_ac, + sizeof(npx_initialstate.sv_87.sv_ac)); intr_restore(s); #ifdef I586_CPU_XXX if (cpu_class == CPUCLASS_586 && npx_ex16 && @@ -785,13 +785,18 @@ npxdna(void) PCPU_SET(fpcurthread, curthread); pcb = PCPU_GET(curpcb); +#ifdef CPU_ENABLE_SSE + if (cpu_fxsr) + fpu_clean_state(); +#endif + if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) { /* * This is the first time this thread has used the FPU or * the PCB doesn't contain a clean FPU state. Explicitly - * load sanitized registers. + * load an initial state. */ - fpurstor(&npx_cleanstate); + fpurstor(&npx_initialstate); if (pcb->pcb_initial_npxcw != __INITIAL_NPXCW__) fldcw(&pcb->pcb_initial_npxcw); pcb->pcb_flags |= PCB_NPXINITDONE; @@ -891,7 +896,7 @@ npxgetregs(td, addr) return (_MC_FPOWNED_NONE); if ((td->td_pcb->pcb_flags & PCB_NPXINITDONE) == 0) { - bcopy(&npx_cleanstate, addr, sizeof(npx_cleanstate)); + bcopy(&npx_initialstate, addr, sizeof(npx_initialstate)); SET_FPU_CW(addr, td->td_pcb->pcb_initial_npxcw); return (_MC_FPOWNED_NONE); } @@ -967,10 +972,10 @@ fpusave(addr) * In order to avoid leaking this information across processes, we clean * these values by performing a dummy load before executing fxrstor(). */ -static double dummy_variable = 0.0; static void fpu_clean_state(void) { + static float dummy_variable = 0.0; u_short status; /* @@ -996,10 +1001,9 @@ fpurstor(addr) { #ifdef CPU_ENABLE_SSE - if (cpu_fxsr) { - fpu_clean_state(); + if (cpu_fxsr) fxrstor(addr); - } else + else #endif frstor(addr); } From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 20:36:00 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43B54106566C; Mon, 4 May 2009 20:36: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 2FD2C8FC1C; Mon, 4 May 2009 20:36:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44Ka0TI056372; Mon, 4 May 2009 20:36:00 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44Ka08v056369; Mon, 4 May 2009 20:36:00 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905042036.n44Ka08v056369@svn.freebsd.org> From: John Baldwin Date: Mon, 4 May 2009 20:36:00 +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: r191795 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 20:36:01 -0000 Author: jhb Date: Mon May 4 20:35:59 2009 New Revision: 191795 URL: http://svn.freebsd.org/changeset/base/191795 Log: MFC: Various fixes to the PCI resource allocation code: - Disabling decoding of BARs via the PCI command register before writing to the BARs to size them. - Don't free resources decoded by a BAR when the device driver releases a BAR. Instead, the PCI bus now owns unclaimed BARs and gives them to drivers on demand. When a driver releases a BAR, the PCI bus reclaims it and leaves the resource range allocated. This also prevents drivers from allocating the same resource multiple times. - Move the activation of BARs by enabling decoding in the PCI command register into bus_activate_resource() so that it always happens after the BAR is fully programmed. - Always read/write the full 64-bit value of 64-bit BARs. - Consolidate duplicated code for reading and sizing BARs and writing base address to BARs. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c stable/7/sys/dev/pci/pci_private.h stable/7/sys/dev/pci/pcireg.h Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon May 4 20:25:56 2009 (r191794) +++ stable/7/sys/dev/pci/pci.c Mon May 4 20:35:59 2009 (r191795) @@ -71,18 +71,17 @@ __FBSDID("$FreeBSD$"); #define ACPI_PWR_FOR_SLEEP(x, y, z) #endif -static uint32_t pci_mapbase(unsigned mapreg); -static const char *pci_maptype(unsigned mapreg); -static int pci_mapsize(unsigned testval); -static int pci_maprange(unsigned mapreg); +static pci_addr_t pci_mapbase(uint64_t mapreg); +static const char *pci_maptype(uint64_t mapreg); +static int pci_mapsize(uint64_t testval); +static int pci_maprange(uint64_t mapreg); static void pci_fixancient(pcicfgregs *cfg); -static int pci_porten(device_t pcib, int b, int s, int f); -static int pci_memen(device_t pcib, int b, int s, int f); +static int pci_porten(device_t dev); +static int pci_memen(device_t dev); static void pci_assign_interrupt(device_t bus, device_t dev, int force_route); -static int pci_add_map(device_t pcib, device_t bus, device_t dev, - int b, int s, int f, int reg, +static int pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, int force, int prefetch); static int pci_probe(device_t dev); static int pci_attach(device_t dev); @@ -136,7 +135,7 @@ static device_method_t pci_methods[] = { DEVMETHOD(bus_delete_resource, pci_delete_resource), DEVMETHOD(bus_alloc_resource, pci_alloc_resource), DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_activate_resource, pci_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), DEVMETHOD(bus_child_location_str, pci_child_location_str_method), @@ -316,8 +315,8 @@ pci_find_device(uint16_t vendor, uint16_ /* return base address of memory or port map */ -static uint32_t -pci_mapbase(uint32_t mapreg) +static pci_addr_t +pci_mapbase(uint64_t mapreg) { if (PCI_BAR_MEM(mapreg)) @@ -329,7 +328,7 @@ pci_mapbase(uint32_t mapreg) /* return map type of memory or port map */ static const char * -pci_maptype(unsigned mapreg) +pci_maptype(uint64_t mapreg) { if (PCI_BAR_IO(mapreg)) @@ -342,7 +341,7 @@ pci_maptype(unsigned mapreg) /* return log2 of map size decoded for memory or port map */ static int -pci_mapsize(uint32_t testval) +pci_mapsize(uint64_t testval) { int ln2size; @@ -361,7 +360,7 @@ pci_mapsize(uint32_t testval) /* return log2 of address range supported by map register */ static int -pci_maprange(unsigned mapreg) +pci_maprange(uint64_t mapreg) { int ln2range = 0; @@ -2257,17 +2256,75 @@ pci_print_verbose(struct pci_devinfo *di } static int -pci_porten(device_t pcib, int b, int s, int f) +pci_porten(device_t dev) { - return (PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2) - & PCIM_CMD_PORTEN) != 0; + return (pci_read_config(dev, PCIR_COMMAND, 2) & PCIM_CMD_PORTEN) != 0; } static int -pci_memen(device_t pcib, int b, int s, int f) +pci_memen(device_t dev) { - return (PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2) - & PCIM_CMD_MEMEN) != 0; + return (pci_read_config(dev, PCIR_COMMAND, 2) & PCIM_CMD_MEMEN) != 0; +} + +static void +pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, pci_addr_t *testvalp) +{ + pci_addr_t map, testval; + int ln2range; + uint16_t cmd; + + map = pci_read_config(dev, reg, 4); + ln2range = pci_maprange(map); + if (ln2range == 64) + map |= (pci_addr_t)pci_read_config(dev, reg + 4, 4) << 32; + + /* + * Disable decoding via the command register before + * determining the BAR's length since we will be placing it in + * a weird state. + */ + cmd = pci_read_config(dev, PCIR_COMMAND, 2); + pci_write_config(dev, PCIR_COMMAND, + cmd & ~(PCI_BAR_MEM(map) ? PCIM_CMD_MEMEN : PCIM_CMD_PORTEN), 2); + + /* + * Determine the BAR's length by writing all 1's. The bottom + * log_2(size) bits of the BAR will stick as 0 when we read + * the value back. + */ + pci_write_config(dev, reg, 0xffffffff, 4); + testval = pci_read_config(dev, reg, 4); + if (ln2range == 64) { + pci_write_config(dev, reg + 4, 0xffffffff, 4); + testval |= (pci_addr_t)pci_read_config(dev, reg + 4, 4) << 32; + } + + /* + * Restore the original value of the BAR. We may have reprogrammed + * the BAR of the low-level console device and when booting verbose, + * we need the console device addressable. + */ + pci_write_config(dev, reg, map, 4); + if (ln2range == 64) + pci_write_config(dev, reg + 4, map >> 32, 4); + pci_write_config(dev, PCIR_COMMAND, cmd, 2); + + *mapp = map; + *testvalp = testval; +} + +static void +pci_write_bar(device_t dev, int reg, pci_addr_t base) +{ + pci_addr_t map; + int ln2range; + + map = pci_read_config(dev, reg, 4); + ln2range = pci_maprange(map); + pci_write_config(dev, reg, base, 4); + if (ln2range == 64) + pci_write_config(dev, reg + 4, base >> 32, 4); } /* @@ -2275,36 +2332,26 @@ pci_memen(device_t pcib, int b, int s, i * register is a 32bit map register or 2 if it is a 64bit register. */ static int -pci_add_map(device_t pcib, device_t bus, device_t dev, - int b, int s, int f, int reg, struct resource_list *rl, int force, - int prefetch) +pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, + int force, int prefetch) { - uint32_t map; - pci_addr_t base; + pci_addr_t base, map, testval; pci_addr_t start, end, count; - uint8_t ln2size; - uint8_t ln2range; - uint32_t testval; + int barlen, maprange, mapsize, type; uint16_t cmd; - int type; - int barlen; struct resource *res; - map = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4); - PCIB_WRITE_CONFIG(pcib, b, s, f, reg, 0xffffffff, 4); - testval = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4); - PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4); - + pci_read_bar(dev, reg, &map, &testval); if (PCI_BAR_MEM(map)) { type = SYS_RES_MEMORY; if (map & PCIM_BAR_MEM_PREFETCH) prefetch = 1; } else type = SYS_RES_IOPORT; - ln2size = pci_mapsize(testval); - ln2range = pci_maprange(testval); + mapsize = pci_mapsize(testval); base = pci_mapbase(map); - barlen = ln2range == 64 ? 2 : 1; + maprange = pci_maprange(map); + barlen = maprange == 64 ? 2 : 1; /* * For I/O registers, if bottom bit is set, and the next bit up @@ -2315,19 +2362,16 @@ pci_add_map(device_t pcib, device_t bus, */ if (PCI_BAR_IO(testval) && (testval & PCIM_BAR_IO_RESERVED) != 0) return (barlen); - if ((type == SYS_RES_MEMORY && ln2size < 4) || - (type == SYS_RES_IOPORT && ln2size < 2)) + if ((type == SYS_RES_MEMORY && mapsize < 4) || + (type == SYS_RES_IOPORT && mapsize < 2)) return (barlen); - if (ln2range == 64) - /* Read the other half of a 64bit map register */ - base |= (uint64_t) PCIB_READ_CONFIG(pcib, b, s, f, reg + 4, 4) << 32; if (bootverbose) { printf("\tmap[%02x]: type %s, range %2d, base %#jx, size %2d", - reg, pci_maptype(map), ln2range, (uintmax_t)base, ln2size); - if (type == SYS_RES_IOPORT && !pci_porten(pcib, b, s, f)) + reg, pci_maptype(map), maprange, (uintmax_t)base, mapsize); + if (type == SYS_RES_IOPORT && !pci_porten(dev)) printf(", port disabled\n"); - else if (type == SYS_RES_MEMORY && !pci_memen(pcib, b, s, f)) + else if (type == SYS_RES_MEMORY && !pci_memen(dev)) printf(", memory disabled\n"); else printf(", enabled\n"); @@ -2349,7 +2393,8 @@ pci_add_map(device_t pcib, device_t bus, if ((u_long)base != base) { device_printf(bus, "pci%d:%d:%d:%d bar %#x too many address bits", - pci_get_domain(dev), b, s, f, reg); + pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), reg); return (barlen); } @@ -2362,30 +2407,30 @@ pci_add_map(device_t pcib, device_t bus, */ if (pci_enable_io_modes) { /* Turn on resources that have been left off by a lazy BIOS */ - if (type == SYS_RES_IOPORT && !pci_porten(pcib, b, s, f)) { - cmd = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2); + if (type == SYS_RES_IOPORT && !pci_porten(dev)) { + cmd = pci_read_config(dev, PCIR_COMMAND, 2); cmd |= PCIM_CMD_PORTEN; - PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, cmd, 2); + pci_write_config(dev, PCIR_COMMAND, cmd, 2); } - if (type == SYS_RES_MEMORY && !pci_memen(pcib, b, s, f)) { - cmd = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2); + if (type == SYS_RES_MEMORY && !pci_memen(dev)) { + cmd = pci_read_config(dev, PCIR_COMMAND, 2); cmd |= PCIM_CMD_MEMEN; - PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, cmd, 2); + pci_write_config(dev, PCIR_COMMAND, cmd, 2); } } else { - if (type == SYS_RES_IOPORT && !pci_porten(pcib, b, s, f)) + if (type == SYS_RES_IOPORT && !pci_porten(dev)) return (barlen); - if (type == SYS_RES_MEMORY && !pci_memen(pcib, b, s, f)) + if (type == SYS_RES_MEMORY && !pci_memen(dev)) return (barlen); } - count = 1 << ln2size; + count = 1 << mapsize; if (base == 0 || base == pci_mapbase(testval)) { start = 0; /* Let the parent decide. */ end = ~0ULL; } else { start = base; - end = base + (1 << ln2size) - 1; + end = base + (1 << mapsize) - 1; } resource_list_add(rl, type, reg, start, end, count); @@ -2406,11 +2451,11 @@ pci_add_map(device_t pcib, device_t bus, */ resource_list_delete(rl, type, reg); start = 0; - } else + } else { start = rman_get_start(res); - pci_write_config(dev, reg, start, 4); - if (ln2range == 64) - pci_write_config(dev, reg + 4, start >> 32, 4); + rman_set_device(res, bus); + } + pci_write_bar(dev, reg, start); return (barlen); } @@ -2422,9 +2467,10 @@ pci_add_map(device_t pcib, device_t bus, * addressing mode. */ static void -pci_ata_maps(device_t pcib, device_t bus, device_t dev, int b, - int s, int f, struct resource_list *rl, int force, uint32_t prefetchmask) +pci_ata_maps(device_t bus, device_t dev, struct resource_list *rl, int force, + uint32_t prefetchmask) { + struct resource *r; int rid, type, progif; #if 0 /* if this device supports PCI native addressing use it */ @@ -2440,38 +2486,42 @@ pci_ata_maps(device_t pcib, device_t bus progif = pci_read_config(dev, PCIR_PROGIF, 1); type = SYS_RES_IOPORT; if (progif & PCIP_STORAGE_IDE_MODEPRIM) { - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(0), rl, force, + pci_add_map(bus, dev, PCIR_BAR(0), rl, force, prefetchmask & (1 << 0)); - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(1), rl, force, + pci_add_map(bus, dev, PCIR_BAR(1), rl, force, prefetchmask & (1 << 1)); } else { rid = PCIR_BAR(0); resource_list_add(rl, type, rid, 0x1f0, 0x1f7, 8); - resource_list_alloc(rl, bus, dev, type, &rid, 0x1f0, 0x1f7, 8, - 0); + r = resource_list_alloc(rl, bus, dev, type, &rid, 0x1f0, 0x1f7, + 8, 0); + rman_set_device(r, bus); rid = PCIR_BAR(1); resource_list_add(rl, type, rid, 0x3f6, 0x3f6, 1); - resource_list_alloc(rl, bus, dev, type, &rid, 0x3f6, 0x3f6, 1, - 0); + r = resource_list_alloc(rl, bus, dev, type, &rid, 0x3f6, 0x3f6, + 1, 0); + rman_set_device(r, bus); } if (progif & PCIP_STORAGE_IDE_MODESEC) { - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(2), rl, force, + pci_add_map(bus, dev, PCIR_BAR(2), rl, force, prefetchmask & (1 << 2)); - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(3), rl, force, + pci_add_map(bus, dev, PCIR_BAR(3), rl, force, prefetchmask & (1 << 3)); } else { rid = PCIR_BAR(2); resource_list_add(rl, type, rid, 0x170, 0x177, 8); - resource_list_alloc(rl, bus, dev, type, &rid, 0x170, 0x177, 8, - 0); + r = resource_list_alloc(rl, bus, dev, type, &rid, 0x170, 0x177, + 8, 0); + rman_set_device(r, bus); rid = PCIR_BAR(3); resource_list_add(rl, type, rid, 0x376, 0x376, 1); - resource_list_alloc(rl, bus, dev, type, &rid, 0x376, 0x376, 1, - 0); + r = resource_list_alloc(rl, bus, dev, type, &rid, 0x376, 0x376, + 1, 0); + rman_set_device(r, bus); } - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(4), rl, force, + pci_add_map(bus, dev, PCIR_BAR(4), rl, force, prefetchmask & (1 << 4)); - pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(5), rl, force, + pci_add_map(bus, dev, PCIR_BAR(5), rl, force, prefetchmask & (1 << 5)); } @@ -2526,18 +2576,11 @@ pci_assign_interrupt(device_t bus, devic void pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask) { - device_t pcib; struct pci_devinfo *dinfo = device_get_ivars(dev); pcicfgregs *cfg = &dinfo->cfg; struct resource_list *rl = &dinfo->resources; struct pci_quirk *q; - int b, i, f, s; - - pcib = device_get_parent(bus); - - b = cfg->bus; - s = cfg->slot; - f = cfg->func; + int i; /* ATA devices needs special map treatment */ if ((pci_get_class(dev) == PCIC_STORAGE) && @@ -2545,11 +2588,11 @@ pci_add_resources(device_t bus, device_t ((pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) || (!pci_read_config(dev, PCIR_BAR(0), 4) && !pci_read_config(dev, PCIR_BAR(2), 4))) ) - pci_ata_maps(pcib, bus, dev, b, s, f, rl, force, prefetchmask); + pci_ata_maps(bus, dev, rl, force, prefetchmask); else for (i = 0; i < cfg->nummaps;) - i += pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(i), - rl, force, prefetchmask & (1 << i)); + i += pci_add_map(bus, dev, PCIR_BAR(i), rl, force, + prefetchmask & (1 << i)); /* * Add additional, quirked resources. @@ -2557,8 +2600,7 @@ pci_add_resources(device_t bus, device_t for (q = &pci_quirks[0]; q->devid; q++) { if (q->devid == ((cfg->device << 16) | cfg->vendor) && q->type == PCI_QUIRK_MAP_REG) - pci_add_map(pcib, bus, dev, b, s, f, q->arg1, rl, - force, 0); + pci_add_map(bus, dev, q->arg1, rl, force, 0); } if (cfg->intpin > 0 && PCI_INTERRUPT_VALID(cfg->intline)) { @@ -3401,21 +3443,12 @@ pci_alloc_map(device_t dev, device_t chi * it fails here, that other code is broken. */ res = NULL; - map = pci_read_config(child, *rid, 4); - pci_write_config(child, *rid, 0xffffffff, 4); - testval = pci_read_config(child, *rid, 4); - if (pci_maprange(testval) == 64) - map |= (pci_addr_t)pci_read_config(child, *rid + 4, 4) << 32; + pci_read_bar(child, *rid, &map, &testval); + + /* Ignore a BAR with a base of 0. */ if (pci_mapbase(testval) == 0) goto out; - /* - * Restore the original value of the BAR. We may have reprogrammed - * the BAR of the low-level console device and when booting verbose, - * we need the console device addressable. - */ - pci_write_config(child, *rid, map, 4); - if (PCI_BAR_MEM(testval)) { if (type != SYS_RES_MEMORY) { if (bootverbose) @@ -3435,6 +3468,7 @@ pci_alloc_map(device_t dev, device_t chi goto out; } } + /* * For real BARs, we need to override the size that * the driver requests, because that's what the BAR @@ -3454,13 +3488,14 @@ pci_alloc_map(device_t dev, device_t chi * appropriate bar for that resource. */ res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, type, rid, - start, end, count, flags); + start, end, count, flags & ~RF_ACTIVE); if (res == NULL) { device_printf(child, "%#lx bytes of rid %#x res %d failed (%#lx, %#lx).\n", count, *rid, type, start, end); goto out; } + rman_set_device(res, dev); resource_list_add(rl, type, *rid, start, end, count); rle = resource_list_find(rl, type, *rid); if (rle == NULL) @@ -3474,10 +3509,8 @@ pci_alloc_map(device_t dev, device_t chi "Lazy allocation of %#lx bytes rid %#x type %d at %#lx\n", count, *rid, type, rman_get_start(res)); map = rman_get_start(res); + pci_write_bar(child, *rid, map); out:; - pci_write_config(child, *rid, map, 4); - if (pci_maprange(testval) == 64) - pci_write_config(child, *rid + 4, map >> 32, 4); return (res); } @@ -3489,68 +3522,63 @@ pci_alloc_resource(device_t dev, device_ struct pci_devinfo *dinfo = device_get_ivars(child); struct resource_list *rl = &dinfo->resources; struct resource_list_entry *rle; + struct resource *res; pcicfgregs *cfg = &dinfo->cfg; + if (device_get_parent(child) != dev) + return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, + type, rid, start, end, count, flags)); + /* * Perform lazy resource allocation */ - if (device_get_parent(child) == dev) { - switch (type) { - case SYS_RES_IRQ: - /* - * Can't alloc legacy interrupt once MSI messages - * have been allocated. - */ - if (*rid == 0 && (cfg->msi.msi_alloc > 0 || - cfg->msix.msix_alloc > 0)) + switch (type) { + case SYS_RES_IRQ: + /* + * Can't alloc legacy interrupt once MSI messages have + * been allocated. + */ + if (*rid == 0 && (cfg->msi.msi_alloc > 0 || + cfg->msix.msix_alloc > 0)) + return (NULL); + + /* + * If the child device doesn't have an interrupt + * routed and is deserving of an interrupt, try to + * assign it one. + */ + if (*rid == 0 && !PCI_INTERRUPT_VALID(cfg->intline) && + (cfg->intpin != 0)) + pci_assign_interrupt(dev, child, 0); + break; + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + /* Allocate resources for this BAR if needed. */ + rle = resource_list_find(rl, type, *rid); + if (rle == NULL) { + res = pci_alloc_map(dev, child, type, rid, start, end, + count, flags); + if (res == NULL) return (NULL); - /* - * If the child device doesn't have an - * interrupt routed and is deserving of an - * interrupt, try to assign it one. - */ - if (*rid == 0 && !PCI_INTERRUPT_VALID(cfg->intline) && - (cfg->intpin != 0)) - pci_assign_interrupt(dev, child, 0); - break; - case SYS_RES_IOPORT: - case SYS_RES_MEMORY: - if (*rid < PCIR_BAR(cfg->nummaps)) { - /* - * Enable the I/O mode. We should - * also be assigning resources too - * when none are present. The - * resource_list_alloc kind of sorta does - * this... - */ - if (PCI_ENABLE_IO(dev, child, type)) - return (NULL); - } rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (pci_alloc_map(dev, child, type, rid, - start, end, count, flags)); - break; } + /* - * If we've already allocated the resource, then - * return it now. But first we may need to activate - * it, since we don't allocate the resource as active - * above. Normally this would be done down in the - * nexus, but since we short-circuit that path we have - * to do its job here. Not sure if we should free the - * resource if it fails to activate. + * If the resource belongs to the bus, then give it to + * the child. We need to activate it if requested + * since the bus always allocates inactive resources. */ - rle = resource_list_find(rl, type, *rid); - if (rle != NULL && rle->res != NULL) { + if (rle != NULL && rle->res != NULL && + rman_get_device(rle->res) == dev) { if (bootverbose) device_printf(child, "Reserved %#lx bytes for rid %#x type %d at %#lx\n", rman_get_size(rle->res), *rid, type, rman_get_start(rle->res)); + rman_set_device(rle->res, child); if ((flags & RF_ACTIVE) && - bus_generic_activate_resource(dev, child, type, - *rid, rle->res) != 0) + bus_activate_resource(child, type, *rid, + rle->res) != 0) return (NULL); return (rle->res); } @@ -3559,6 +3587,59 @@ pci_alloc_resource(device_t dev, device_ start, end, count, flags)); } +int +pci_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + int error; + + if (device_get_parent(child) != dev) + return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + type, rid, r)); + + /* + * For BARs we don't actually want to release the resource. + * Instead, we deactivate the resource if needed and then give + * ownership of the BAR back to the bus. + */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + if (rman_get_device(r) != child) + return (EINVAL); + if (rman_get_flags(r) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, r); + if (error) + return (error); + } + rman_set_device(r, dev); + return (0); + } + return (bus_generic_rl_release_resource(dev, child, type, rid, r)); +} + +int +pci_activate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + int error; + + error = bus_generic_activate_resource(dev, child, type, rid, r); + if (error) + return (error); + + /* Enable decoding in the command register when activating BARs. */ + if (device_get_parent(child) == dev) { + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + error = PCI_ENABLE_IO(dev, child, type); + break; + } + } + return (error); +} + void pci_delete_resource(device_t dev, device_t child, int type, int rid) { @@ -3572,27 +3653,33 @@ pci_delete_resource(device_t dev, device dinfo = device_get_ivars(child); rl = &dinfo->resources; rle = resource_list_find(rl, type, rid); - if (rle) { - if (rle->res) { - if (rman_get_device(rle->res) != dev || - rman_get_flags(rle->res) & RF_ACTIVE) { - device_printf(dev, "delete_resource: " - "Resource still owned by child, oops. " - "(type=%d, rid=%d, addr=%lx)\n", - rle->type, rle->rid, - rman_get_start(rle->res)); - return; - } - bus_release_resource(dev, type, rid, rle->res); + if (rle == NULL) + return; + + if (rle->res) { + if (rman_get_device(rle->res) != dev || + rman_get_flags(rle->res) & RF_ACTIVE) { + device_printf(dev, "delete_resource: " + "Resource still owned by child, oops. " + "(type=%d, rid=%d, addr=%lx)\n", + rle->type, rle->rid, + rman_get_start(rle->res)); + return; } - resource_list_delete(rl, type, rid); + + /* + * If this is a BAR, clear the BAR so it stops + * decoding before releasing the resource. + */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + pci_write_bar(child, rid, 0); + break; + } + bus_release_resource(dev, type, rid, rle->res); } - /* - * Why do we turn off the PCI configuration BAR when we delete a - * resource? -- imp - */ - pci_write_config(child, rid, 0, 4); - BUS_DELETE_RESOURCE(device_get_parent(dev), child, type, rid); + resource_list_delete(rl, type, rid); } struct resource_list * Modified: stable/7/sys/dev/pci/pci_private.h ============================================================================== --- stable/7/sys/dev/pci/pci_private.h Mon May 4 20:25:56 2009 (r191794) +++ stable/7/sys/dev/pci/pci_private.h Mon May 4 20:35:59 2009 (r191795) @@ -82,6 +82,10 @@ int pci_msix_count_method(device_t dev, struct resource *pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); +int pci_release_resource(device_t dev, device_t child, int type, + int rid, struct resource *r); +int pci_activate_resource(device_t dev, device_t child, int type, + int rid, struct resource *r); void pci_delete_resource(device_t dev, device_t child, int type, int rid); struct resource_list *pci_get_resource_list (device_t dev, device_t child); Modified: stable/7/sys/dev/pci/pcireg.h ============================================================================== --- stable/7/sys/dev/pci/pcireg.h Mon May 4 20:25:56 2009 (r191794) +++ stable/7/sys/dev/pci/pcireg.h Mon May 4 20:35:59 2009 (r191795) @@ -130,7 +130,7 @@ #define PCIM_BAR_MEM_1MB 2 /* Locate below 1MB in PCI <= 2.1 */ #define PCIM_BAR_MEM_64 4 #define PCIM_BAR_MEM_PREFETCH 0x00000008 -#define PCIM_BAR_MEM_BASE 0xfffffff0 +#define PCIM_BAR_MEM_BASE 0xfffffffffffffff0ULL #define PCIM_BAR_IO_RESERVED 0x00000002 #define PCIM_BAR_IO_BASE 0xfffffffc #define PCIR_CIS 0x28 From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 20:48:07 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C420D106564A; Mon, 4 May 2009 20:48:07 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B18308FC0C; Mon, 4 May 2009 20:48:07 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44Km7vd056704; Mon, 4 May 2009 20:48:07 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44Km7tA056703; Mon, 4 May 2009 20:48:07 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200905042048.n44Km7tA056703@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 4 May 2009 20:48:07 +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: r191796 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 20:48:08 -0000 Author: emax Date: Mon May 4 20:48:07 2009 New Revision: 191796 URL: http://svn.freebsd.org/changeset/base/191796 Log: MFC r191366 Fix sbappendrecord_locked(). The main problem is that sbappendrecord_locked() relies on sbcompress() to set sb_mbtail. This will not happen if sbappendrecord_locked() is called with mbuf chain made of exactly one mbuf (i.e. m0->m_next == NULL). In this case sbcompress() will be called with m == NULL and will do nothing. I'm not entirely sure if m == NULL is a valid argument for sbcompress(), and, it rather pointless to call it like that, but keep calling it so it can do SBLASTMBUFCHK(). PR: kern/126742 Investigated by: pluknet < pluknet -at- gmail -dot- com > No response from: freebsd-current@, freebsd-bluetooth@ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/uipc_sockbuf.c Modified: stable/7/sys/kern/uipc_sockbuf.c ============================================================================== --- stable/7/sys/kern/uipc_sockbuf.c Mon May 4 20:35:59 2009 (r191795) +++ stable/7/sys/kern/uipc_sockbuf.c Mon May 4 20:48:07 2009 (r191796) @@ -576,10 +576,6 @@ sbappendrecord_locked(struct sockbuf *sb if (m0 == 0) return; - m = sb->sb_mb; - if (m) - while (m->m_nextpkt) - m = m->m_nextpkt; /* * Put the first mbuf on the queue. Note this permits zero length * records. @@ -587,16 +583,14 @@ sbappendrecord_locked(struct sockbuf *sb sballoc(sb, m0); SBLASTRECORDCHK(sb); SBLINKRECORD(sb, m0); - if (m) - m->m_nextpkt = m0; - else - sb->sb_mb = m0; + sb->sb_mbtail = m0; m = m0->m_next; m0->m_next = 0; if (m && (m0->m_flags & M_EOR)) { m0->m_flags &= ~M_EOR; m->m_flags |= M_EOR; } + /* always call sbcompress() so it can do SBLASTMBUFCHK() */ sbcompress(sb, m, m0); } From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 20:53:19 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBDF21065691; Mon, 4 May 2009 20:53:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C80C08FC13; Mon, 4 May 2009 20:53:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44KrJCT056855; Mon, 4 May 2009 20:53:19 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44KrJjg056851; Mon, 4 May 2009 20:53:19 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200905042053.n44KrJjg056851@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 4 May 2009 20:53:19 +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: r191797 - stable/7/lib/libbluetooth X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 20:53:21 -0000 Author: emax Date: Mon May 4 20:53:19 2009 New Revision: 191797 URL: http://svn.freebsd.org/changeset/base/191797 Log: MFC r191388 Implement low-level Bluetooth HCI API. This should make it easier to make Linux BlueZ libhci port. Reviewed by: Iain Hibbert < plunky -at- rya-online -dot- net > of NetBSD Inspired by: Linux BlueZ Inspired by: NetBSD Modified: stable/7/lib/libbluetooth/ (props changed) stable/7/lib/libbluetooth/Makefile stable/7/lib/libbluetooth/bluetooth.3 stable/7/lib/libbluetooth/bluetooth.h stable/7/lib/libbluetooth/hci.c Modified: stable/7/lib/libbluetooth/Makefile ============================================================================== --- stable/7/lib/libbluetooth/Makefile Mon May 4 20:48:07 2009 (r191796) +++ stable/7/lib/libbluetooth/Makefile Mon May 4 20:53:19 2009 (r191797) @@ -33,6 +33,19 @@ MLINKS+= bluetooth.3 bt_devname.3 MLINKS+= bluetooth.3 bt_devinfo.3 MLINKS+= bluetooth.3 bt_devenum.3 +MLINKS+= bluetooth.3 bt_devopen.3 +MLINKS+= bluetooth.3 bt_devclose.3 +MLINKS+= bluetooth.3 bt_devsend.3 +MLINKS+= bluetooth.3 bt_devreq.3 +MLINKS+= bluetooth.3 bt_devfilter.3 +MLINKS+= bluetooth.3 bt_devfilter_pkt_set.3 +MLINKS+= bluetooth.3 bt_devfilter_pkt_clr.3 +MLINKS+= bluetooth.3 bt_devfilter_pkt_tst.3 +MLINKS+= bluetooth.3 bt_devfilter_evt_set.3 +MLINKS+= bluetooth.3 bt_devfilter_evt_clr.3 +MLINKS+= bluetooth.3 bt_devfilter_evt_tst.3 +MLINKS+= bluetooth.3 bt_devinquiry.3 + MLINKS+= bluetooth.3 bdaddr_same.3 MLINKS+= bluetooth.3 bdaddr_any.3 MLINKS+= bluetooth.3 bdaddr_copy.3 Modified: stable/7/lib/libbluetooth/bluetooth.3 ============================================================================== --- stable/7/lib/libbluetooth/bluetooth.3 Mon May 4 20:48:07 2009 (r191796) +++ stable/7/lib/libbluetooth/bluetooth.3 Mon May 4 20:53:19 2009 (r191797) @@ -25,7 +25,7 @@ .\" $Id: bluetooth.3,v 1.5 2003/05/20 23:04:30 max Exp $ .\" $FreeBSD$ .\" -.Dd February 13, 2009 +.Dd April 9, 2009 .Dt BLUETOOTH 3 .Os .Sh NAME @@ -41,6 +41,23 @@ .Nm bt_endprotoent , .Nm bt_aton , .Nm bt_ntoa , +.Nm bt_devaddr , +.Nm bt_devname , +.Nm bt_devinfo , +.Nm bt_devenum , +.Nm bt_devopen , +.Nm bt_devclose , +.Nm bt_devsend , +.Nm bt_devrecv , +.Nm bt_devreq , +.Nm bt_devfilter , +.Nm bt_devfilter_pkt_set , +.Nm bt_devfilter_pkt_clr , +.Nm bt_devfilter_pkt_tst , +.Nm bt_devfilter_evt_set , +.Nm bt_devfilter_evt_clr , +.Nm bt_devfilter_evt_tst , +.Nm bt_devinquiry , .Nm bdaddr_same , .Nm bdaddr_any , .Nm bdaddr_copy @@ -84,6 +101,32 @@ .Ft int .Fn bt_devenum "bt_devenum_cb_t *cb" "void *arg" .Ft int +.Fn bt_devopen "char const *devname" +.Ft int +.Fn bt_devclose "int s" +.Ft int +.Fn bt_devsend "int s" "uint16_t opcode" "void *param" "size_t plen" +.Ft ssize_t +.Fn bt_devrecv "int s" "void *buf" "size_t size" "time_t to" +.Ft int +.Fn bt_devreq "int s" "struct bt_devreq *r" "time_t to" +.Ft int +.Fn bt_devfilter "int s" "struct bt_devfilter const *new" "struct bt_devfilter *old" +.Ft void +.Fn bt_devfilter_pkt_set "struct bt_devfilter *filter" "uint8_t type" +.Ft void +.Fn bt_devfilter_pkt_clt "struct bt_devfilter *filter" "uint8_t type" +.Ft int +.Fn bt_devfilter_pkt_tst "struct bt_devfilter const *filter" "uint8_t type" +.Ft void +.Fn bt_devfilter_evt_set "struct bt_devfilter *filter" "uint8_t event" +.Ft void +.Fn bt_devfilter_evt_clt "struct bt_devfilter *filter" "uint8_t event" +.Ft int +.Fn bt_devfilter_evt_tst "struct bt_devfilter const *filter" "uint8_t event" +.Ft int +.Fn bt_devinquiry "char const *devname" "time_t length" "int num_rsp" "struct bt_devinquiry **ii" +.Ft int .Fn bdaddr_same "const bdaddr_t *a" "const bdaddr_t *b" .Ft int .Fn bdaddr_any "const bdaddr_t *a" @@ -311,6 +354,240 @@ The function returns number of successfu or -1 if an error occurred. .Pp The +.Fn bt_devopen +function opens a Bluetooth device with the given +.Fa devname +and returns a connected and bound +.Dv HCI +socket handle. +The function returns -1 if an error has occurred. +.Pp +The +.Fn bt_devclose +closes the passed +.Dv HCI +socket handle +.Fa s , +previously obtained with +.Xr bt_devopen 3 . +.Pp +The +.Fn bt_devsend +function sends a Bluetooth +.Dv HCI +command with the given +.Fa opcode +to the provided socket +.Fa s , +previously obtained with +.Xr bt_devopen 3 . +The +.Fa opcode +parameter is exppected to be in the host byte order. +The +.Fa param +and +.Fa plen +parameters specify command parameters. +The +.Fn bt_devsend +function does not modify the +.Dv HCI +filter on the provided socket +.Fa s . +The function returns 0 on success, +or -1 if an error occurred. +.Pp +The +.Fn bt_devrecv +function receives one Bluetooth +.Dv HCI +packet from the socket +.Fa s , +previously obtained with +.Xr bt_devopen 3 . +The packet is placed into the provided buffer +.Fa buf +of size +.Fa size . +The +.Fa to +parameter specifies receive timeout in seconds. +Infinite timeout can be specified by passing negative value in the +.Fa to +parameter. +The +.Fn bt_devrecv +function does not modify the +.Dv HCI +filter on the provided socket +.Fa s . +The function returns total number of bytes recevied, +or -1 if an error occurred. +.Pp +The +.Fn bt_devreq +function makes a Bluetooth +.Dv HCI +request to the socket +.Fa s , +previously obtained with +.Xr bt_devopen 3 . +The function will send the specified command and will wait for the specified +event, +or timeout +.Fa to +seconds to occur. +The +.Vt bt_devreq +structure is defined as follows +.Bd -literal -offset indent +struct bt_devreq +{ + uint16_t opcode; + uint8_t event; + void *cparam; + size_t clen; + void *rparam; + size_t rlen; +}; +.Ed +.Pp +The +.Fa opcode +field specifies the command and is expected to be in the host byte order. +The +.Fa cparam +and +.Fa clen +fields specify command parameters data and command parameters data size +respectively. +The +.Fa event +field specifies which Bluetooth +.Dv HCI +event ID the function should wait for, otherwise it should be set to zero. +The +.Dv HCI +Command Complete and Command Status events are enabled by default. +The +.Fa rparam +and +.Fa rlen +parameters specify buffer and buffer size respectively where return +parameters should be placed. +The +.Fn bt_devreq +function temporarily modifies filter on the provided +.Dv HCI +socket +.Fa s . +The function returns 0 on success, or -1 if an error occurred. +.Pp +The +.Fn bt_devfilter +controls the local +.Dv HCI +filter associated with the socket +.Fa s , +previously obtained with +.Xr bt_devopen 3 . +Filtering can be done on packet types, i.e. +.Dv ACL , +.Dv SCO or +.Dv HCI , +command and event packets, and, in addition, on +.Dv HCI +event IDs. +Before applying the +.Fa new +filter (if provided) the function will try to obtain the current filter +from the socket +.Fa s +and place it into the +.Fa old +parameter (if provided). +The function returns 0 on success, or -1 if an error occurred. +.Pp +The +.Fn bt_devfilter_pkt_set , +.Fn bt_devfilter_pkt_clr +and +.Fn bt_devfilter_pkt_tst +functions can be used to modify and test the +.Dv HCI +filter +.Fa filter . +The +.Fa type +parameter specifies +.Dv HCI +packet type. +.Pp +The +.Fn bt_devfilter_evt_set , +.Fn bt_devfilter_evt_clr +and +.Fn bt_devfilter_evt_tst +functions can be used to modify and test the +.Dv HCI +event filter +.Fa filter . +The +.Fa event +parameter specifies +.Dv HCI +event ID. +.Pp +The +.Fn bt_devinquiry +function performs Bluetooth inquiry. +The +.Fa devname +parameter specifies which local Bluetooth device should perform an inquiry. +If not secified, i.e. +.Dv NULL , +then first available device will be used. +The +.Fa length +parameters specifies the total length of an inquiry in seconds. +If not specified, i.e. 0, default value will be used. +The +.Fa num_rsp +parameter specifies the number of responses that can be received before +the inquiry is halted. +If not specified, i.e. 0, default value will be used. +The +.Fa ii +parameter specifies where to place inquiry results. +On success, the function will return total number of inquiry results, +will allocate, +using +.Xr calloc 3 , +buffer to store all the inquiry results and +will return pointer to the allocated buffer in the +.Fa ii +parameter. +It is up to the caller of the function to dispose of the buffer using +.Xr free 3 +call. +The function returns -1 if an error has occurred. +The +.Vt bt_devinquiry +structure is defined as follows +.Bd -literal -offset indent +struct bt_devinquiry { + bdaddr_t bdaddr; + uint8_t pscan_rep_mode; + uint8_t pscan_period_mode; + uint8_t dev_class[3]; + uint16_t clock_offset; + int8_t rssi; + uint8_t data[240]; +}; +.Ed +.Pp +The .Fn bdaddr_same , .Fn bdaddr_any and @@ -444,6 +721,6 @@ will be bound and connected to the Bluet .Sh AUTHORS .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com .Sh BUGS -These functions use static data storage; +Some of those functions use static data storage; if the data is needed for future use, it should be copied before any subsequent calls overwrite it. Modified: stable/7/lib/libbluetooth/bluetooth.h ============================================================================== --- stable/7/lib/libbluetooth/bluetooth.h Mon May 4 20:48:07 2009 (r191796) +++ stable/7/lib/libbluetooth/bluetooth.h Mon May 4 20:53:19 2009 (r191797) @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include #include #include +#include __BEGIN_DECLS @@ -129,8 +131,48 @@ struct bt_devinfo uint8_t _padding[20]; /* leave space for future additions */ }; +struct bt_devreq +{ + uint16_t opcode; + uint8_t event; + void *cparam; + size_t clen; + void *rparam; + size_t rlen; +}; + +struct bt_devfilter { + bitstr_t bit_decl(packet_mask, 8); + bitstr_t bit_decl(event_mask, 256); +}; + +struct bt_devinquiry { + bdaddr_t bdaddr; + uint8_t pscan_rep_mode; + uint8_t pscan_period_mode; + uint8_t dev_class[3]; + uint16_t clock_offset; + int8_t rssi; + uint8_t data[240]; +}; + typedef int (bt_devenum_cb_t)(int, struct bt_devinfo const *, void *); +int bt_devopen (char const *devname); +int bt_devclose(int s); +int bt_devsend (int s, uint16_t opcode, void *param, size_t plen); +ssize_t bt_devrecv (int s, void *buf, size_t size, time_t to); +int bt_devreq (int s, struct bt_devreq *r, time_t to); +int bt_devfilter(int s, struct bt_devfilter const *new, + struct bt_devfilter *old); +void bt_devfilter_pkt_set(struct bt_devfilter *filter, uint8_t type); +void bt_devfilter_pkt_clr(struct bt_devfilter *filter, uint8_t type); +int bt_devfilter_pkt_tst(struct bt_devfilter const *filter, uint8_t type); +void bt_devfilter_evt_set(struct bt_devfilter *filter, uint8_t event); +void bt_devfilter_evt_clr(struct bt_devfilter *filter, uint8_t event); +int bt_devfilter_evt_tst(struct bt_devfilter const *filter, uint8_t event); +int bt_devinquiry(char const *devname, time_t length, int num_rsp, + struct bt_devinquiry **ii); int bt_devinfo (struct bt_devinfo *di); int bt_devenum (bt_devenum_cb_t *cb, void *arg); Modified: stable/7/lib/libbluetooth/hci.c ============================================================================== --- stable/7/lib/libbluetooth/hci.c Mon May 4 20:48:07 2009 (r191796) +++ stable/7/lib/libbluetooth/hci.c Mon May 4 20:53:19 2009 (r191797) @@ -30,15 +30,505 @@ * $FreeBSD$ */ +#include #include +#include #include #include #include #include +#undef MIN +#define MIN(a, b) (((a) < (b))? (a) : (b)) + +static int bt_devany_cb(int s, struct bt_devinfo const *di, void *xdevname); static char * bt_dev2node (char const *devname, char *nodename, int nnlen); int +bt_devopen(char const *devname) +{ + struct sockaddr_hci ha; + bdaddr_t ba; + int s; + + if (devname == NULL) { + errno = EINVAL; + return (-1); + } + + memset(&ha, 0, sizeof(ha)); + ha.hci_len = sizeof(ha); + ha.hci_family = AF_BLUETOOTH; + + if (bt_aton(devname, &ba)) { + if (!bt_devname(ha.hci_node, &ba)) + return (-1); + } else if (bt_dev2node(devname, ha.hci_node, + sizeof(ha.hci_node)) == NULL) { + errno = ENXIO; + return (-1); + } + + s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); + if (s < 0) + return (-1); + + if (bind(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || + connect(s, (struct sockaddr *) &ha, sizeof(ha)) < 0) { + close(s); + return (-1); + } + + return (s); +} + +int +bt_devclose(int s) +{ + return (close(s)); +} + +int +bt_devsend(int s, uint16_t opcode, void *param, size_t plen) +{ + ng_hci_cmd_pkt_t h; + struct iovec iv[2]; + int ivn; + + if ((plen == 0 && param != NULL) || + (plen > 0 && param == NULL) || + plen > UINT8_MAX) { + errno = EINVAL; + return (-1); + } + + iv[0].iov_base = &h; + iv[0].iov_len = sizeof(h); + ivn = 1; + + h.type = NG_HCI_CMD_PKT; + h.opcode = htole16(opcode); + if (plen > 0) { + h.length = plen; + + iv[1].iov_base = param; + iv[1].iov_len = plen; + ivn = 2; + } else + h.length = 0; + + while (writev(s, iv, ivn) < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + + return (-1); + } + + return (0); +} + +ssize_t +bt_devrecv(int s, void *buf, size_t size, time_t to) +{ + ssize_t n; + + if (buf == NULL || size == 0) { + errno = EINVAL; + return (-1); + } + + if (to >= 0) { + fd_set rfd; + struct timeval tv; + + FD_ZERO(&rfd); + FD_SET(s, &rfd); + + tv.tv_sec = to; + tv.tv_usec = 0; + + while ((n = select(s + 1, &rfd, NULL, NULL, &tv)) < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + + return (-1); + } + + if (n == 0) { + errno = ETIMEDOUT; + return (-1); + } + + assert(FD_ISSET(s, &rfd)); + } + + while ((n = read(s, buf, size)) < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + + return (-1); + } + + switch (*((uint8_t *) buf)) { + case NG_HCI_CMD_PKT: { + ng_hci_cmd_pkt_t *h = (ng_hci_cmd_pkt_t *) buf; + + if (n >= sizeof(*h) && n == (sizeof(*h) + h->length)) + return (n); + } break; + + case NG_HCI_ACL_DATA_PKT: { + ng_hci_acldata_pkt_t *h = (ng_hci_acldata_pkt_t *) buf; + + if (n >= sizeof(*h) && n == (sizeof(*h) + le16toh(h->length))) + return (n); + } break; + + case NG_HCI_SCO_DATA_PKT: { + ng_hci_scodata_pkt_t *h = (ng_hci_scodata_pkt_t *) buf; + + if (n >= sizeof(*h) && n == (sizeof(*h) + h->length)) + return (n); + } break; + + case NG_HCI_EVENT_PKT: { + ng_hci_event_pkt_t *h = (ng_hci_event_pkt_t *) buf; + + if (n >= sizeof(*h) && n == (sizeof(*h) + h->length)) + return (n); + } break; + } + + errno = EIO; + return (-1); +} + +int +bt_devreq(int s, struct bt_devreq *r, time_t to) +{ + uint8_t buf[320]; /* more than enough */ + ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) buf; + ng_hci_command_compl_ep *cc = (ng_hci_command_compl_ep *)(e+1); + ng_hci_command_status_ep *cs = (ng_hci_command_status_ep*)(e+1); + struct bt_devfilter old, new; + time_t t_end; + uint16_t opcode; + ssize_t n; + int error; + + if (s < 0 || r == NULL || to < 0) { + errno = EINVAL; + return (-1); + } + + if ((r->rlen == 0 && r->rparam != NULL) || + (r->rlen > 0 && r->rparam == NULL)) { + errno = EINVAL; + return (-1); + } + + memset(&new, 0, sizeof(new)); + bt_devfilter_pkt_set(&new, NG_HCI_EVENT_PKT); + bt_devfilter_evt_set(&new, NG_HCI_EVENT_COMMAND_COMPL); + bt_devfilter_evt_set(&new, NG_HCI_EVENT_COMMAND_STATUS); + if (r->event != 0) + bt_devfilter_evt_set(&new, r->event); + + if (bt_devfilter(s, &new, &old) < 0) + return (-1); + + error = 0; + + n = bt_devsend(s, r->opcode, r->cparam, r->clen); + if (n < 0) { + error = errno; + goto out; + } + + opcode = htole16(r->opcode); + t_end = time(NULL) + to; + + do { + to = t_end - time(NULL); + if (to < 0) + to = 0; + + n = bt_devrecv(s, buf, sizeof(buf), to); + if (n < 0) { + error = errno; + goto out; + } + + if (e->type != NG_HCI_EVENT_PKT) { + error = EIO; + goto out; + } + + n -= sizeof(*e); + + switch (e->event) { + case NG_HCI_EVENT_COMMAND_COMPL: + if (cc->opcode == opcode) { + n -= sizeof(*cc); + + if (r->rlen >= n) { + r->rlen = n; + memcpy(r->rparam, cc + 1, r->rlen); + } + + goto out; + } + break; + + case NG_HCI_EVENT_COMMAND_STATUS: + if (cs->opcode == opcode) { + if (r->event != NG_HCI_EVENT_COMMAND_STATUS) { + if (cs->status != 0) { + error = EIO; + goto out; + } + } else { + if (r->rlen >= n) { + r->rlen = n; + memcpy(r->rparam, cs, r->rlen); + } + + goto out; + } + } + break; + + default: + if (e->event == r->event) { + if (r->rlen >= n) { + r->rlen = n; + memcpy(r->rparam, e + 1, r->rlen); + } + + goto out; + } + break; + } + } while (to > 0); + + error = ETIMEDOUT; +out: + bt_devfilter(s, &old, NULL); + + if (error != 0) { + errno = error; + return (-1); + } + + return (0); +} + +int +bt_devfilter(int s, struct bt_devfilter const *new, struct bt_devfilter *old) +{ + struct ng_btsocket_hci_raw_filter f; + socklen_t len; + + if (new == NULL && old == NULL) { + errno = EINVAL; + return (-1); + } + + if (old != NULL) { + len = sizeof(f); + if (getsockopt(s, SOL_HCI_RAW, SO_HCI_RAW_FILTER, &f, &len) < 0) + return (-1); + + memset(old, 0, sizeof(*old)); + memcpy(old->packet_mask, &f.packet_mask, + MIN(sizeof(old->packet_mask), sizeof(f.packet_mask))); + memcpy(old->event_mask, &f.event_mask, + MIN(sizeof(old->event_mask), sizeof(f.packet_mask))); + } + + if (new != NULL) { + memset(&f, 0, sizeof(f)); + memcpy(&f.packet_mask, new->packet_mask, + MIN(sizeof(f.packet_mask), sizeof(new->event_mask))); + memcpy(&f.event_mask, new->event_mask, + MIN(sizeof(f.event_mask), sizeof(new->event_mask))); + + len = sizeof(f); + if (setsockopt(s, SOL_HCI_RAW, SO_HCI_RAW_FILTER, &f, len) < 0) + return (-1); + } + + return (0); +} + +void +bt_devfilter_pkt_set(struct bt_devfilter *filter, uint8_t type) +{ + bit_set(filter->packet_mask, type - 1); +} + +void +bt_devfilter_pkt_clr(struct bt_devfilter *filter, uint8_t type) +{ + bit_clear(filter->packet_mask, type - 1); +} + +int +bt_devfilter_pkt_tst(struct bt_devfilter const *filter, uint8_t type) +{ + return (bit_test(filter->packet_mask, type - 1)); +} + +void +bt_devfilter_evt_set(struct bt_devfilter *filter, uint8_t event) +{ + bit_set(filter->event_mask, event - 1); +} + +void +bt_devfilter_evt_clr(struct bt_devfilter *filter, uint8_t event) +{ + bit_clear(filter->event_mask, event - 1); +} + +int +bt_devfilter_evt_tst(struct bt_devfilter const *filter, uint8_t event) +{ + return (bit_test(filter->event_mask, event - 1)); +} + +int +bt_devinquiry(char const *devname, time_t length, int num_rsp, + struct bt_devinquiry **ii) +{ + uint8_t buf[320]; + char _devname[HCI_DEVNAME_SIZE]; + struct bt_devfilter f; + ng_hci_inquiry_cp *cp = (ng_hci_inquiry_cp *) buf; + ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) buf; + ng_hci_inquiry_result_ep *ep = (ng_hci_inquiry_result_ep *)(e+1); + ng_hci_inquiry_response *ir; + struct bt_devinquiry *i; + int s, n; + time_t to; + + if (ii == NULL) { + errno = EINVAL; + return (-1); + } + + if (devname == NULL) { + memset(_devname, 0, sizeof(_devname)); + devname = _devname; + + n = bt_devenum(bt_devany_cb, _devname); + if (n <= 0) { + if (n == 0) + *ii = NULL; + + return (n); + } + } + + s = bt_devopen(devname); + if (s < 0) + return (-1); + + if (bt_devfilter(s, NULL, &f) < 0) { + bt_devclose(s); + return (-1); + } + + bt_devfilter_evt_set(&f, NG_HCI_EVENT_INQUIRY_COMPL); + bt_devfilter_evt_set(&f, NG_HCI_EVENT_INQUIRY_RESULT); + + if (bt_devfilter(s, &f, NULL) < 0) { + bt_devclose(s); + return (-1); + } + + /* Always use GIAC LAP */ + cp->lap[0] = 0x33; + cp->lap[1] = 0x8b; + cp->lap[2] = 0x9e; + + /* Calculate inquire length in 1.28 second units */ + to = (time_t) ((double) length / 1.28); + if (to <= 0) + cp->inquiry_length = 4; /* 5.12 seconds */ + else if (to > 254) + cp->inquiry_length = 255; /* 326.40 seconds */ + else + cp->inquiry_length = to + 1; + + to = (time_t)((double) cp->inquiry_length * 1.28) + 1; + + if (num_rsp <= 0 || num_rsp > 255) + num_rsp = 8; + cp->num_responses = (uint8_t) num_rsp; + + i = *ii = calloc(num_rsp, sizeof(struct bt_devinquiry)); + if (i == NULL) { + bt_devclose(s); + errno = ENOMEM; + return (-1); + } + + if (bt_devsend(s, + NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_INQUIRY), + cp, sizeof(*cp)) < 0) { + free(i); + bt_devclose(s); + return (-1); + } + +wait_for_more: + + n = bt_devrecv(s, buf, sizeof(buf), to); + if (n < 0) { + free(i); + bt_devclose(s); + return (-1); + } + + if (n < sizeof(ng_hci_event_pkt_t)) { + free(i); + bt_devclose(s); + errno = EIO; + return (-1); + } + + switch (e->event) { + case NG_HCI_EVENT_INQUIRY_COMPL: + break; + + case NG_HCI_EVENT_INQUIRY_RESULT: + ir = (ng_hci_inquiry_response *)(ep + 1); + + for (n = 0; n < MIN(ep->num_responses, num_rsp); n ++) { + bdaddr_copy(&i->bdaddr, &ir->bdaddr); + i->pscan_rep_mode = ir->page_scan_rep_mode; + i->pscan_period_mode = ir->page_scan_period_mode; + memcpy(i->dev_class, ir->uclass, sizeof(i->dev_class)); + i->clock_offset = le16toh(ir->clock_offset); + + ir ++; + i ++; + num_rsp --; + } + /* FALLTHROUGH */ + + default: + goto wait_for_more; + /* NOT REACHED */ + } + + bt_devclose(s); + + return (i - *ii); +} + +int bt_devinfo(struct bt_devinfo *di) { union { @@ -53,6 +543,7 @@ bt_devinfo(struct bt_devinfo *di) struct ng_btsocket_hci_raw_node_debug r8; } rp; struct sockaddr_hci ha; + socklen_t halen; int s, rval; if (di == NULL) { @@ -60,27 +551,14 @@ bt_devinfo(struct bt_devinfo *di) return (-1); } - memset(&ha, 0, sizeof(ha)); - ha.hci_len = sizeof(ha); - ha.hci_family = AF_BLUETOOTH; - - if (bt_aton(di->devname, &rp.r1.bdaddr)) { - if (!bt_devname(ha.hci_node, &rp.r1.bdaddr)) - return (-1); - } else if (bt_dev2node(di->devname, ha.hci_node, - sizeof(ha.hci_node)) == NULL) { - errno = ENXIO; - return (-1); - } - - s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); + s = bt_devopen(di->devname); if (s < 0) return (-1); rval = -1; - if (bind(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || - connect(s, (struct sockaddr *) &ha, sizeof(ha)) < 0) + halen = sizeof(ha); + if (getsockname(s, (struct sockaddr *) &ha, &halen) < 0) goto bad; strlcpy(di->devname, ha.hci_node, sizeof(di->devname)); @@ -138,7 +616,7 @@ bt_devinfo(struct bt_devinfo *di) rval = 0; bad: - close(s); + bt_devclose(s); return (rval); } @@ -205,6 +683,13 @@ bt_devenum(bt_devenum_cb_t cb, void *arg return (count); } +static int +bt_devany_cb(int s, struct bt_devinfo const *di, void *xdevname) +{ + strlcpy((char *) xdevname, di->devname, HCI_DEVNAME_SIZE); + return (1); +} + static char * bt_dev2node(char const *devname, char *nodename, int nnlen) { From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 21:00:44 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BD031065676; Mon, 4 May 2009 21:00:44 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 28AA68FC20; Mon, 4 May 2009 21:00:44 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44L0ia4057078; Mon, 4 May 2009 21:00:44 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44L0icR057077; Mon, 4 May 2009 21:00:44 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200905042100.n44L0icR057077@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 4 May 2009 21:00:44 +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: r191798 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/syscons X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 21:00:45 -0000 Author: emax Date: Mon May 4 21:00:43 2009 New Revision: 191798 URL: http://svn.freebsd.org/changeset/base/191798 Log: MFC r190868 Remove obsolete/bogus layering. Reviewed by: freebsd-current@, freebsd-hackers@ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/syscons/syscons.c Modified: stable/7/sys/dev/syscons/syscons.c ============================================================================== --- stable/7/sys/dev/syscons/syscons.c Mon May 4 20:53:19 2009 (r191797) +++ stable/7/sys/dev/syscons/syscons.c Mon May 4 21:00:43 2009 (r191798) @@ -184,7 +184,6 @@ static void scshutdown(void *arg, int ho static u_int scgetc(sc_softc_t *sc, u_int flags); #define SCGETC_CN 1 #define SCGETC_NONBLOCK 2 -static int sccngetch(int flags); static void sccnupdate(scr_stat *scp); static scr_stat *alloc_scp(sc_softc_t *sc, int vty); static void init_scp(sc_softc_t *sc, int vty, scr_stat *scp); @@ -1569,12 +1568,6 @@ sc_cnputc(struct consdev *cd, int c) static int sc_cngetc(struct consdev *cd) { - return sccngetch(SCGETC_NONBLOCK); -} - -static int -sccngetch(int flags) -{ static struct fkeytab fkey; static int fkeycp; scr_stat *scp; @@ -1615,7 +1608,7 @@ sccngetch(int flags) kbd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); kbd_poll(scp->sc->kbd, TRUE); - c = scgetc(scp->sc, SCGETC_CN | flags); + c = scgetc(scp->sc, SCGETC_CN | SCGETC_NONBLOCK); kbd_poll(scp->sc->kbd, FALSE); scp->kbd_mode = cur_mode; From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 21:04:29 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8416F106566B; Mon, 4 May 2009 21:04:29 +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 6F4B38FC12; Mon, 4 May 2009 21:04:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44L4Tbb057211; Mon, 4 May 2009 21:04:29 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44L4TcW057206; Mon, 4 May 2009 21:04:29 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905042104.n44L4TcW057206@svn.freebsd.org> From: John Baldwin Date: Mon, 4 May 2009 21:04: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: r191799 - in stable/7/sys: . amd64/include amd64/pci contrib/pf dev/acpica dev/ath/ath_hal dev/cxgb i386/include i386/pci X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 21:04:30 -0000 Author: jhb Date: Mon May 4 21:04:29 2009 New Revision: 191799 URL: http://svn.freebsd.org/changeset/base/191799 Log: MFC: Expand the support for PCI-e memory mapped configuration space access. Note that unlike in HEAD, this defaults to off and must be explicitly enabled by setting the loader tunable hw.pci.mcfg=1. - Add support for the Intel 915GM chipsets by reading the BAR. - Add parsing of the ACPI MCFG table to discover memory mapped configuration access on modern machines. - Port the memory mapped config acess to amd64. On amd64 it uses the direct map. - For config requests to busses not listed in ACPI's min/max valid buses, fall back to using type #1 configuration access instead. - Add a workaround for some K8 chipsets that do not expose all devices on bus 0 via MCFG and fall back to type #1 for those devices instead. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/include/pci_cfgreg.h stable/7/sys/amd64/pci/pci_cfgreg.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpica/acpi.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/i386/include/pci_cfgreg.h stable/7/sys/i386/pci/pci_cfgreg.c Modified: stable/7/sys/amd64/include/pci_cfgreg.h ============================================================================== --- stable/7/sys/amd64/include/pci_cfgreg.h Mon May 4 21:00:43 2009 (r191798) +++ stable/7/sys/amd64/include/pci_cfgreg.h Mon May 4 21:04:29 2009 (r191799) @@ -37,6 +37,7 @@ #define CONF1_ENABLE_MSK1 0x80000001ul #define CONF1_ENABLE_RES1 0x80000000ul +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); int pci_cfgregopen(void); u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); Modified: stable/7/sys/amd64/pci/pci_cfgreg.c ============================================================================== --- stable/7/sys/amd64/pci/pci_cfgreg.c Mon May 4 21:00:43 2009 (r191798) +++ stable/7/sys/amd64/pci/pci_cfgreg.c Mon May 4 21:04:29 2009 (r191799) @@ -33,15 +33,36 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include +#include +#include #include +enum { + CFGMECH_NONE = 0, + CFGMECH_1, + CFGMECH_PCIE, +}; + +static uint32_t pci_docfgregread(int bus, int slot, int func, int reg, + int bytes); +static int pciereg_cfgread(int bus, unsigned slot, unsigned func, + unsigned reg, unsigned bytes); +static void pciereg_cfgwrite(int bus, unsigned slot, unsigned func, + unsigned reg, int data, unsigned bytes); static int pcireg_cfgread(int bus, int slot, int func, int reg, int bytes); static void pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes); +static int cfgmech; +static vm_offset_t pcie_base; +static int pcie_minbus, pcie_maxbus; +static uint32_t pcie_badslots; static struct mtx pcicfg_mtx; +static int mcfg_enable = 0; +TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); /* * Initialise access to PCI configuration space @@ -49,15 +70,62 @@ static struct mtx pcicfg_mtx; int pci_cfgregopen(void) { - static int opened = 0; + static int once = 0; + uint64_t pciebar; + uint16_t did, vid; + + if (!once) { + mtx_init(&pcicfg_mtx, "pcicfg", NULL, MTX_SPIN); + once = 1; + } - if (opened) + if (cfgmech != CFGMECH_NONE) return (1); - mtx_init(&pcicfg_mtx, "pcicfg", NULL, MTX_SPIN); - opened = 1; + cfgmech = CFGMECH_1; + + /* + * Grope around in the PCI config space to see if this is a + * chipset that is capable of doing memory-mapped config cycles. + * This also implies that it can do PCIe extended config cycles. + */ + + /* Check for supported chipsets */ + vid = pci_cfgregread(0, 0, 0, PCIR_VENDOR, 2); + did = pci_cfgregread(0, 0, 0, PCIR_DEVICE, 2); + switch (vid) { + case 0x8086: + switch (did) { + case 0x3590: + case 0x3592: + /* Intel 7520 or 7320 */ + pciebar = pci_cfgregread(0, 0, 0, 0xce, 2) << 16; + pcie_cfgregopen(pciebar, 0, 255); + break; + case 0x2580: + case 0x2584: + case 0x2590: + /* Intel 915, 925, or 915GM */ + pciebar = pci_cfgregread(0, 0, 0, 0x48, 4); + pcie_cfgregopen(pciebar, 0, 255); + break; + } + } + return (1); } +static uint32_t +pci_docfgregread(int bus, int slot, int func, int reg, int bytes) +{ + + if (cfgmech == CFGMECH_PCIE && + (bus >= pcie_minbus && bus <= pcie_maxbus) && + (bus != 0 || !(1 << slot & pcie_badslots))) + return (pciereg_cfgread(bus, slot, func, reg, bytes)); + else + return (pcireg_cfgread(bus, slot, func, reg, bytes)); +} + /* * Read configuration space register */ @@ -75,12 +143,12 @@ pci_cfgregread(int bus, int slot, int fu * as an invalid IRQ. */ if (reg == PCIR_INTLINE && bytes == 1) { - line = pcireg_cfgread(bus, slot, func, PCIR_INTLINE, 1); + line = pci_docfgregread(bus, slot, func, PCIR_INTLINE, 1); if (line == 0 || line >= 128) line = PCI_INVALID_IRQ; return (line); } - return (pcireg_cfgread(bus, slot, func, reg, bytes)); + return (pci_docfgregread(bus, slot, func, reg, bytes)); } /* @@ -90,7 +158,12 @@ void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes) { - pcireg_cfgwrite(bus, slot, func, reg, data, bytes); + if (cfgmech == CFGMECH_PCIE && + (bus >= pcie_minbus && bus <= pcie_maxbus) && + (bus != 0 || !(1 << slot & pcie_badslots))) + pciereg_cfgwrite(bus, slot, func, reg, data, bytes); + else + pcireg_cfgwrite(bus, slot, func, reg, data, bytes); } /* @@ -173,3 +246,106 @@ pcireg_cfgwrite(int bus, int slot, int f } mtx_unlock_spin(&pcicfg_mtx); } + +int +pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus) +{ + uint32_t val1, val2; + int slot; + + if (!mcfg_enable) + return (0); + + if (minbus != 0) + return (0); + + if (bootverbose) + printf("PCIe: Memory Mapped configuration base @ 0x%lx\n", + base); + + /* XXX: We should make sure this really fits into the direct map. */ + pcie_base = (vm_offset_t)pmap_mapdev(base, (maxbus + 1) << 20); + pcie_minbus = minbus; + pcie_maxbus = maxbus; + cfgmech = CFGMECH_PCIE; + + /* + * On some AMD systems, some of the devices on bus 0 are + * inaccessible using memory-mapped PCI config access. Walk + * bus 0 looking for such devices. For these devices, we will + * fall back to using type 1 config access instead. + */ + if (pci_cfgregopen() != 0) { + for (slot = 0; slot < 32; slot++) { + val1 = pcireg_cfgread(0, slot, 0, 0, 4); + if (val1 == 0xffffffff) + continue; + + val2 = pciereg_cfgread(0, slot, 0, 0, 4); + if (val2 != val1) + pcie_badslots |= (1 << slot); + } + } + + return (1); +} + +#define PCIE_VADDR(base, reg, bus, slot, func) \ + ((base) + \ + ((((bus) & 0xff) << 20) | \ + (((slot) & 0x1f) << 15) | \ + (((func) & 0x7) << 12) | \ + ((reg) & 0xfff))) + +static int +pciereg_cfgread(int bus, unsigned slot, unsigned func, unsigned reg, + unsigned bytes) +{ + volatile vm_offset_t va; + int data = -1; + + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000) + return (-1); + + va = PCIE_VADDR(pcie_base, reg, bus, slot, func); + + switch (bytes) { + case 4: + data = *(volatile uint32_t *)(va); + break; + case 2: + data = *(volatile uint16_t *)(va); + break; + case 1: + data = *(volatile uint8_t *)(va); + break; + } + + return (data); +} + +static void +pciereg_cfgwrite(int bus, unsigned slot, unsigned func, unsigned reg, int data, + unsigned bytes) +{ + volatile vm_offset_t va; + + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000) + return; + + va = PCIE_VADDR(pcie_base, reg, bus, slot, func); + + switch (bytes) { + case 4: + *(volatile uint32_t *)(va) = data; + break; + case 2: + *(volatile uint16_t *)(va) = data; + break; + case 1: + *(volatile uint8_t *)(va) = data; + break; + } +} Modified: stable/7/sys/dev/acpica/acpi.c ============================================================================== --- stable/7/sys/dev/acpica/acpi.c Mon May 4 21:00:43 2009 (r191798) +++ stable/7/sys/dev/acpica/acpi.c Mon May 4 21:04:29 2009 (r191799) @@ -48,6 +48,9 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__i386__) || defined(__amd64__) +#include +#endif #include #include #include @@ -153,6 +156,9 @@ static int acpi_child_location_str_metho char *buf, size_t buflen); static int acpi_child_pnpinfo_str_method(device_t acdev, device_t child, char *buf, size_t buflen); +#if defined(__i386__) || defined(__amd64__) +static void acpi_enable_pcie(void); +#endif static device_method_t acpi_methods[] = { /* Device interface */ @@ -455,6 +461,11 @@ acpi_attach(device_t dev) goto out; } +#if defined(__i386__) || defined(__amd64__) + /* Handle MCFG table if present. */ + acpi_enable_pcie(); +#endif + /* Install the default address space handlers. */ status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL); @@ -1473,6 +1484,36 @@ acpi_isa_pnp_probe(device_t bus, device_ return_VALUE (result); } +#if defined(__i386__) || defined(__amd64__) +/* + * Look for a MCFG table. If it is present, use the settings for + * domain (segment) 0 to setup PCI config space access via the memory + * map. + */ +static void +acpi_enable_pcie(void) +{ + ACPI_TABLE_HEADER *hdr; + ACPI_MCFG_ALLOCATION *alloc, *end; + ACPI_STATUS status; + + status = AcpiGetTable(ACPI_SIG_MCFG, 1, &hdr); + if (ACPI_FAILURE(status)) + return; + + end = (ACPI_MCFG_ALLOCATION *)((char *)hdr + hdr->Length); + alloc = (ACPI_MCFG_ALLOCATION *)((ACPI_TABLE_MCFG *)hdr + 1); + while (alloc < end) { + if (alloc->PciSegment == 0) { + pcie_cfgregopen(alloc->Address, alloc->StartBusNumber, + alloc->EndBusNumber); + return; + } + alloc++; + } +} +#endif + /* * Scan all of the ACPI namespace and attach child devices. * Modified: stable/7/sys/i386/include/pci_cfgreg.h ============================================================================== --- stable/7/sys/i386/include/pci_cfgreg.h Mon May 4 21:00:43 2009 (r191798) +++ stable/7/sys/i386/include/pci_cfgreg.h Mon May 4 21:04:29 2009 (r191799) @@ -43,6 +43,7 @@ #define CONF2_ENABLE_CHK 0x0e #define CONF2_ENABLE_RES 0x0e +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); int pci_cfgregopen(void); u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); Modified: stable/7/sys/i386/pci/pci_cfgreg.c ============================================================================== --- stable/7/sys/i386/pci/pci_cfgreg.c Mon May 4 21:00:43 2009 (r191798) +++ stable/7/sys/i386/pci/pci_cfgreg.c Mon May 4 21:04:29 2009 (r191799) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -75,20 +76,24 @@ enum { }; static TAILQ_HEAD(pcie_cfg_list, pcie_cfg_elem) pcie_list[MAXCPU]; -static uint32_t pciebar; +static uint64_t pcie_base; +static int pcie_minbus, pcie_maxbus; +static uint32_t pcie_badslots; static int cfgmech; static int devmax; static struct mtx pcicfg_mtx; +static int mcfg_enable = 0; +TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); +static uint32_t pci_docfgregread(int bus, int slot, int func, int reg, + int bytes); static int pcireg_cfgread(int bus, int slot, int func, int reg, int bytes); static void pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes); static int pcireg_cfgopen(void); - -static int pciereg_cfgopen(void); -static int pciereg_cfgread(int bus, int slot, int func, int reg, - int bytes); -static void pciereg_cfgwrite(int bus, int slot, int func, int reg, - int data, int bytes); +static int pciereg_cfgread(int bus, unsigned slot, unsigned func, + unsigned reg, unsigned bytes); +static void pciereg_cfgwrite(int bus, unsigned slot, unsigned func, + unsigned reg, int data, unsigned bytes); /* * Some BIOS writers seem to want to ignore the spec and put @@ -133,14 +138,15 @@ int pci_cfgregopen(void) { static int opened = 0; + uint64_t pciebar; u_int16_t vid, did; u_int16_t v; if (opened) - return(1); + return (1); - if (pcireg_cfgopen() == 0) - return(0); + if (cfgmech == CFGMECH_NONE && pcireg_cfgopen() == 0) + return (0); v = pcibios_get_version(); if (v > 0) @@ -153,6 +159,9 @@ pci_cfgregopen(void) if (v >= 0x0210) pci_pir_open(); + if (cfgmech == CFGMECH_PCIE) + return (1); + /* * Grope around in the PCI config space to see if this is a * chipset that is capable of doing memory-mapped config cycles. @@ -162,21 +171,40 @@ pci_cfgregopen(void) /* Check for supported chipsets */ vid = pci_cfgregread(0, 0, 0, PCIR_VENDOR, 2); did = pci_cfgregread(0, 0, 0, PCIR_DEVICE, 2); - if (vid == 0x8086) { - if (did == 0x3590 || did == 0x3592) { + switch (vid) { + case 0x8086: + switch (did) { + case 0x3590: + case 0x3592: /* Intel 7520 or 7320 */ pciebar = pci_cfgregread(0, 0, 0, 0xce, 2) << 16; - pciereg_cfgopen(); - } else if (did == 0x2580 || did == 0x2584) { - /* Intel 915 or 925 */ + pcie_cfgregopen(pciebar, 0, 255); + break; + case 0x2580: + case 0x2584: + case 0x2590: + /* Intel 915, 925, or 915GM */ pciebar = pci_cfgregread(0, 0, 0, 0x48, 4); - pciereg_cfgopen(); + pcie_cfgregopen(pciebar, 0, 255); + break; } } return(1); } +static uint32_t +pci_docfgregread(int bus, int slot, int func, int reg, int bytes) +{ + + if (cfgmech == CFGMECH_PCIE && + (bus >= pcie_minbus && bus <= pcie_maxbus) && + (bus != 0 || !(1 << slot & pcie_badslots))) + return (pciereg_cfgread(bus, slot, func, reg, bytes)); + else + return (pcireg_cfgread(bus, slot, func, reg, bytes)); +} + /* * Read configuration space register */ @@ -191,10 +219,10 @@ pci_cfgregread(int bus, int slot, int fu * the code uses 255 as an invalid IRQ. */ if (reg == PCIR_INTLINE && bytes == 1) { - line = pcireg_cfgread(bus, slot, func, PCIR_INTLINE, 1); + line = pci_docfgregread(bus, slot, func, PCIR_INTLINE, 1); return (pci_i386_map_intline(line)); } - return (pcireg_cfgread(bus, slot, func, reg, bytes)); + return (pci_docfgregread(bus, slot, func, reg, bytes)); } /* @@ -204,7 +232,12 @@ void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes) { - pcireg_cfgwrite(bus, slot, func, reg, data, bytes); + if (cfgmech == CFGMECH_PCIE && + (bus >= pcie_minbus && bus <= pcie_maxbus) && + (bus != 0 || !(1 << slot & pcie_badslots))) + pciereg_cfgwrite(bus, slot, func, reg, data, bytes); + else + pcireg_cfgwrite(bus, slot, func, reg, data, bytes); } /* @@ -258,6 +291,7 @@ pci_cfgenable(unsigned bus, unsigned slo && (unsigned) bytes <= 4 && (reg & (bytes - 1)) == 0) { switch (cfgmech) { + case CFGMECH_PCIE: case CFGMECH_1: outl(CONF1_ADDR_PORT, (1 << 31) | (bus << 16) | (slot << 11) @@ -279,6 +313,7 @@ static void pci_cfgdisable(void) { switch (cfgmech) { + case CFGMECH_PCIE: case CFGMECH_1: /* * Do nothing for the config mechanism 1 case. @@ -299,11 +334,6 @@ pcireg_cfgread(int bus, int slot, int fu int data = -1; int port; - if (cfgmech == CFGMECH_PCIE) { - data = pciereg_cfgread(bus, slot, func, reg, bytes); - return (data); - } - mtx_lock_spin(&pcicfg_mtx); port = pci_cfgenable(bus, slot, func, reg, bytes); if (port != 0) { @@ -329,11 +359,6 @@ pcireg_cfgwrite(int bus, int slot, int f { int port; - if (cfgmech == CFGMECH_PCIE) { - pciereg_cfgwrite(bus, slot, func, reg, data, bytes); - return; - } - mtx_lock_spin(&pcicfg_mtx); port = pci_cfgenable(bus, slot, func, reg, bytes); if (port != 0) { @@ -481,8 +506,8 @@ pcireg_cfgopen(void) return (cfgmech); } -static int -pciereg_cfgopen(void) +int +pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus) { struct pcie_cfg_list *pcielist; struct pcie_cfg_elem *pcie_array, *elem; @@ -490,10 +515,28 @@ pciereg_cfgopen(void) struct pcpu *pc; #endif vm_offset_t va; - int i; + uint32_t val1, val2; + int i, slot; + if (!mcfg_enable) + return (0); + + if (minbus != 0) + return (0); + +#ifndef PAE + if (base >= 0x100000000) { + if (bootverbose) + printf( + "PCI: Memory Mapped PCI configuration area base 0x%jx too high\n", + (uintmax_t)base); + return (0); + } +#endif + if (bootverbose) - printf("Setting up PCIe mappings for BAR 0x%x\n", pciebar); + printf("PCIe: Memory Mapped configuration base @ 0x%jx\n", + (uintmax_t)base); #ifdef SMP SLIST_FOREACH(pc, &cpuhead, pc_allcpu) @@ -525,9 +568,30 @@ pciereg_cfgopen(void) } } - + pcie_base = base; + pcie_minbus = minbus; + pcie_maxbus = maxbus; cfgmech = CFGMECH_PCIE; devmax = 32; + + /* + * On some AMD systems, some of the devices on bus 0 are + * inaccessible using memory-mapped PCI config access. Walk + * bus 0 looking for such devices. For these devices, we will + * fall back to using type 1 config access instead. + */ + if (pci_cfgregopen() != 0) { + for (slot = 0; slot < 32; slot++) { + val1 = pcireg_cfgread(0, slot, 0, 0, 4); + if (val1 == 0xffffffff) + continue; + + val2 = pciereg_cfgread(0, slot, 0, 0, 4); + if (val2 != val1) + pcie_badslots |= (1 << slot); + } + } + return (1); } @@ -574,15 +638,20 @@ pciereg_findelem(vm_paddr_t papage) } static int -pciereg_cfgread(int bus, int slot, int func, int reg, int bytes) +pciereg_cfgread(int bus, unsigned slot, unsigned func, unsigned reg, + unsigned bytes) { struct pcie_cfg_elem *elem; volatile vm_offset_t va; vm_paddr_t pa, papage; - int data; + int data = -1; + + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000 || bytes > 4 || bytes == 3) + return (-1); critical_enter(); - pa = PCIE_PADDR(pciebar, reg, bus, slot, func); + pa = PCIE_PADDR(pcie_base, reg, bus, slot, func); papage = pa & ~PAGE_MASK; elem = pciereg_findelem(papage); va = elem->vapage | (pa & PAGE_MASK); @@ -597,8 +666,6 @@ pciereg_cfgread(int bus, int slot, int f case 1: data = *(volatile uint8_t *)(va); break; - default: - panic("pciereg_cfgread: invalid width"); } critical_exit(); @@ -606,14 +673,19 @@ pciereg_cfgread(int bus, int slot, int f } static void -pciereg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes) +pciereg_cfgwrite(int bus, unsigned slot, unsigned func, unsigned reg, int data, + unsigned bytes) { struct pcie_cfg_elem *elem; volatile vm_offset_t va; vm_paddr_t pa, papage; + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000) + return; + critical_enter(); - pa = PCIE_PADDR(pciebar, reg, bus, slot, func); + pa = PCIE_PADDR(pcie_base, reg, bus, slot, func); papage = pa & ~PAGE_MASK; elem = pciereg_findelem(papage); va = elem->vapage | (pa & PAGE_MASK); @@ -628,8 +700,6 @@ pciereg_cfgwrite(int bus, int slot, int case 1: *(volatile uint8_t *)(va) = data; break; - default: - panic("pciereg_cfgwrite: invalid width"); } critical_exit(); From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 21:13:06 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 817AC106564A; Mon, 4 May 2009 21:13:06 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6EE088FC1A; Mon, 4 May 2009 21:13:06 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44LD6pQ057441; Mon, 4 May 2009 21:13:06 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44LD6gt057440; Mon, 4 May 2009 21:13:06 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200905042113.n44LD6gt057440@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 4 May 2009 21:13: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: r191800 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/kbd X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 21:13:07 -0000 Author: emax Date: Mon May 4 21:13:06 2009 New Revision: 191800 URL: http://svn.freebsd.org/changeset/base/191800 Log: MFC r190869 Introduce KB_POLLED flag to struct keyboard's kb_flags field. Reviewed by: freebsd-current@, freebsd-hackers@ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/kbd/kbdreg.h Modified: stable/7/sys/dev/kbd/kbdreg.h ============================================================================== --- stable/7/sys/dev/kbd/kbdreg.h Mon May 4 21:04:29 2009 (r191799) +++ stable/7/sys/dev/kbd/kbdreg.h Mon May 4 21:13:06 2009 (r191800) @@ -60,6 +60,7 @@ struct keyboard { #define KB_INITIALIZED (1 << 19) /* device initialized */ #define KB_REGISTERED (1 << 20) /* device registered to kbdio */ #define KB_BUSY (1 << 21) /* device used by a client */ +#define KB_POLLED (1 << 22) /* device is polled */ int kb_active; /* 0: inactive */ void *kb_token; /* id of the current client */ keyboard_callback_t kb_callback;/* callback function */ @@ -107,6 +108,9 @@ struct keyboard { #define KBD_IS_BUSY(k) ((k)->kb_flags & KB_BUSY) #define KBD_BUSY(k) ((k)->kb_flags |= KB_BUSY) #define KBD_UNBUSY(k) ((k)->kb_flags &= ~KB_BUSY) +#define KBD_IS_POLLED(k) ((k)->kb_flags & KB_POLLED) +#define KBD_POLL(k) ((k)->kb_flags |= KB_POLLED) +#define KBD_UNPOLL(k) ((k)->kb_flags &= ~KB_POLLED) #define KBD_IS_ACTIVE(k) ((k)->kb_active) #define KBD_ACTIVATE(k) (++(k)->kb_active) #define KBD_DEACTIVATE(k) (--(k)->kb_active) From owner-svn-src-stable-7@FreeBSD.ORG Mon May 4 21:58:33 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32389106564A; Mon, 4 May 2009 21:58: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 04B5D8FC1D; Mon, 4 May 2009 21:58:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n44LwWvi058515; Mon, 4 May 2009 21:58:32 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n44LwWjX058513; Mon, 4 May 2009 21:58:32 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905042158.n44LwWjX058513@svn.freebsd.org> From: John Baldwin Date: Mon, 4 May 2009 21:58:32 +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: r191801 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2009 21:58:33 -0000 Author: jhb Date: Mon May 4 21:58:32 2009 New Revision: 191801 URL: http://svn.freebsd.org/changeset/base/191801 Log: MFC: When a file lookup fails due to encountering a doomed vnode from a forced unmount, consistently return ENOENT rather than EBADF. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_cache.c stable/7/sys/kern/vfs_lookup.c Modified: stable/7/sys/kern/vfs_cache.c ============================================================================== --- stable/7/sys/kern/vfs_cache.c Mon May 4 21:13:06 2009 (r191800) +++ stable/7/sys/kern/vfs_cache.c Mon May 4 21:58:32 2009 (r191801) @@ -318,7 +318,7 @@ cache_zap(ncp) * (negative cacheing), a status of ENOENT is returned. If the lookup * fails, a status of zero is returned. If the directory vnode is * recycled out from under us due to a forced unmount, a status of - * EBADF is returned. + * ENOENT is returned. * * vpp is locked and ref'd on return. If we're looking up DOTDOT, dvp is * unlocked. If we're looking up . an extra ref is taken, but the lock is @@ -466,7 +466,7 @@ success: /* forced unmount */ vrele(*vpp); *vpp = NULL; - return (EBADF); + return (ENOENT); } } else vn_lock(*vpp, LK_DOWNGRADE | LK_RETRY, td); @@ -939,7 +939,7 @@ vn_fullpath1(struct thread *td, struct v while (vp != rdir && vp != rootvnode) { if (vp->v_vflag & VV_ROOT) { if (vp->v_iflag & VI_DOOMED) { /* forced unmount */ - error = EBADF; + error = ENOENT; break; } vp = vp->v_mount->mnt_vnodecovered; Modified: stable/7/sys/kern/vfs_lookup.c ============================================================================== --- stable/7/sys/kern/vfs_lookup.c Mon May 4 21:13:06 2009 (r191800) +++ stable/7/sys/kern/vfs_lookup.c Mon May 4 21:58:32 2009 (r191801) @@ -532,7 +532,7 @@ dirloop: if ((dp->v_vflag & VV_ROOT) == 0) break; if (dp->v_iflag & VI_DOOMED) { /* forced unmount */ - error = EBADF; + error = ENOENT; goto bad; } tdp = dp; @@ -691,9 +691,11 @@ unionlookup: *ndp->ni_next == '/')) { cnp->cn_flags |= ISSYMLINK; if (dp->v_iflag & VI_DOOMED) { - /* We can't know whether the directory was mounted with - * NOSYMFOLLOW, so we can't follow safely. */ - error = EBADF; + /* + * We can't know whether the directory was mounted with + * NOSYMFOLLOW, so we can't follow safely. + */ + error = ENOENT; goto bad2; } if (dp->v_mount->mnt_flag & MNT_NOSYMFOLLOW) { From owner-svn-src-stable-7@FreeBSD.ORG Tue May 5 03:49:30 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 921981065676; Tue, 5 May 2009 03:49:30 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 764D38FC08; Tue, 5 May 2009 03:49:30 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n453nUAi066182; Tue, 5 May 2009 03:49:30 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n453nUCR066177; Tue, 5 May 2009 03:49:30 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200905050349.n453nUCR066177@svn.freebsd.org> From: Dmitry Chagin Date: Tue, 5 May 2009 03:49: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: r191804 - in stable/7/sys: . amd64/linux32 contrib/pf dev/ath/ath_hal dev/cxgb i386/linux X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2009 03:49:31 -0000 Author: dchagin Date: Tue May 5 03:49:30 2009 New Revision: 191804 URL: http://svn.freebsd.org/changeset/base/191804 Log: Merge r178257 (jkim) from HEAD to stable/7: Add stubs for syscalls introduced in Linux 2.6.17 kernel. Some GNU libc version started using them before 2.6.17 was officially out. Approved by: kib (mentor) Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/linux32/linux32_dummy.c stable/7/sys/amd64/linux32/syscalls.master stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/i386/linux/linux_dummy.c stable/7/sys/i386/linux/syscalls.master Modified: stable/7/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- stable/7/sys/amd64/linux32/linux32_dummy.c Tue May 5 01:13:20 2009 (r191803) +++ stable/7/sys/amd64/linux32/linux32_dummy.c Tue May 5 03:49:30 2009 (r191804) @@ -111,6 +111,12 @@ DUMMY(faccessat); DUMMY(pselect6); DUMMY(ppoll); DUMMY(unshare); +DUMMY(set_robust_list); +DUMMY(get_robust_list); +DUMMY(splice); +DUMMY(sync_file_range); +DUMMY(tee); +DUMMY(vmsplice); #define DUMMY_XATTR(s) \ int \ Modified: stable/7/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/7/sys/amd64/linux32/syscalls.master Tue May 5 01:13:20 2009 (r191803) +++ stable/7/sys/amd64/linux32/syscalls.master Tue May 5 03:49:30 2009 (r191804) @@ -482,3 +482,9 @@ 308 AUE_NULL STD { int linux_pselect6(void); } 309 AUE_NULL STD { int linux_ppoll(void); } 310 AUE_NULL STD { int linux_unshare(void); } +311 AUE_NULL STD { int linux_set_robust_list(void); } +312 AUE_NULL STD { int linux_get_robust_list(void); } +313 AUE_NULL STD { int linux_splice(void); } +314 AUE_NULL STD { int linux_sync_file_range(void); } +315 AUE_NULL STD { int linux_tee(void); } +316 AUE_NULL STD { int linux_vmsplice(void); } Modified: stable/7/sys/i386/linux/linux_dummy.c ============================================================================== --- stable/7/sys/i386/linux/linux_dummy.c Tue May 5 01:13:20 2009 (r191803) +++ stable/7/sys/i386/linux/linux_dummy.c Tue May 5 03:49:30 2009 (r191804) @@ -102,6 +102,12 @@ DUMMY(faccessat); DUMMY(pselect6); DUMMY(ppoll); DUMMY(unshare); +DUMMY(set_robust_list); +DUMMY(get_robust_list); +DUMMY(splice); +DUMMY(sync_file_range); +DUMMY(tee); +DUMMY(vmsplice); #define DUMMY_XATTR(s) \ int \ Modified: stable/7/sys/i386/linux/syscalls.master ============================================================================== --- stable/7/sys/i386/linux/syscalls.master Tue May 5 01:13:20 2009 (r191803) +++ stable/7/sys/i386/linux/syscalls.master Tue May 5 03:49:30 2009 (r191804) @@ -492,3 +492,9 @@ 308 AUE_NULL STD { int linux_pselect6(void); } 309 AUE_NULL STD { int linux_ppoll(void); } 310 AUE_NULL STD { int linux_unshare(void); } +311 AUE_NULL STD { int linux_set_robust_list(void); } +312 AUE_NULL STD { int linux_get_robust_list(void); } +313 AUE_NULL STD { int linux_splice(void); } +314 AUE_NULL STD { int linux_sync_file_range(void); } +315 AUE_NULL STD { int linux_tee(void); } +316 AUE_NULL STD { int linux_vmsplice(void); } From owner-svn-src-stable-7@FreeBSD.ORG Tue May 5 03:51:41 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A194D106567A; Tue, 5 May 2009 03:51:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8ECFF8FC1F; Tue, 5 May 2009 03:51:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n453pfdw066269; Tue, 5 May 2009 03:51:41 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n453pfbQ066263; Tue, 5 May 2009 03:51:41 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200905050351.n453pfbQ066263@svn.freebsd.org> From: Dmitry Chagin Date: Tue, 5 May 2009 03:51:41 +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: r191805 - in stable/7/sys: amd64/linux32 i386/linux X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2009 03:51:42 -0000 Author: dchagin Date: Tue May 5 03:51:41 2009 New Revision: 191805 URL: http://svn.freebsd.org/changeset/base/191805 Log: Regenerate syscall table after r191804. Approved by: kib (mentor) Modified: stable/7/sys/amd64/linux32/linux32_proto.h stable/7/sys/amd64/linux32/linux32_syscall.h stable/7/sys/amd64/linux32/linux32_sysent.c stable/7/sys/i386/linux/linux_proto.h stable/7/sys/i386/linux/linux_syscall.h stable/7/sys/i386/linux/linux_sysent.c Modified: stable/7/sys/amd64/linux32/linux32_proto.h ============================================================================== --- stable/7/sys/amd64/linux32/linux32_proto.h Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/amd64/linux32/linux32_proto.h Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #ifndef _LINUX_SYSPROTO_H_ @@ -936,6 +936,24 @@ struct linux_ppoll_args { struct linux_unshare_args { register_t dummy; }; +struct linux_set_robust_list_args { + register_t dummy; +}; +struct linux_get_robust_list_args { + register_t dummy; +}; +struct linux_splice_args { + register_t dummy; +}; +struct linux_sync_file_range_args { + register_t dummy; +}; +struct linux_tee_args { + register_t dummy; +}; +struct linux_vmsplice_args { + register_t dummy; +}; #define nosys linux_nosys int linux_fork(struct thread *, struct linux_fork_args *); int linux_open(struct thread *, struct linux_open_args *); @@ -1172,6 +1190,12 @@ int linux_faccessat(struct thread *, str int linux_pselect6(struct thread *, struct linux_pselect6_args *); int linux_ppoll(struct thread *, struct linux_ppoll_args *); int linux_unshare(struct thread *, struct linux_unshare_args *); +int linux_set_robust_list(struct thread *, struct linux_set_robust_list_args *); +int linux_get_robust_list(struct thread *, struct linux_get_robust_list_args *); +int linux_splice(struct thread *, struct linux_splice_args *); +int linux_sync_file_range(struct thread *, struct linux_sync_file_range_args *); +int linux_tee(struct thread *, struct linux_tee_args *); +int linux_vmsplice(struct thread *, struct linux_vmsplice_args *); #ifdef COMPAT_43 @@ -1428,6 +1452,12 @@ int linux_unshare(struct thread *, struc #define LINUX_SYS_AUE_linux_pselect6 AUE_NULL #define LINUX_SYS_AUE_linux_ppoll AUE_NULL #define LINUX_SYS_AUE_linux_unshare AUE_NULL +#define LINUX_SYS_AUE_linux_set_robust_list AUE_NULL +#define LINUX_SYS_AUE_linux_get_robust_list AUE_NULL +#define LINUX_SYS_AUE_linux_splice AUE_NULL +#define LINUX_SYS_AUE_linux_sync_file_range AUE_NULL +#define LINUX_SYS_AUE_linux_tee AUE_NULL +#define LINUX_SYS_AUE_linux_vmsplice AUE_NULL #undef PAD_ #undef PADL_ Modified: stable/7/sys/amd64/linux32/linux32_syscall.h ============================================================================== --- stable/7/sys/amd64/linux32/linux32_syscall.h Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/amd64/linux32/linux32_syscall.h Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #define LINUX_SYS_exit 1 @@ -283,4 +283,10 @@ #define LINUX_SYS_linux_pselect6 308 #define LINUX_SYS_linux_ppoll 309 #define LINUX_SYS_linux_unshare 310 -#define LINUX_SYS_MAXSYSCALL 311 +#define LINUX_SYS_linux_set_robust_list 311 +#define LINUX_SYS_linux_get_robust_list 312 +#define LINUX_SYS_linux_splice 313 +#define LINUX_SYS_linux_sync_file_range 314 +#define LINUX_SYS_linux_tee 315 +#define LINUX_SYS_linux_vmsplice 316 +#define LINUX_SYS_MAXSYSCALL 317 Modified: stable/7/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- stable/7/sys/amd64/linux32/linux32_sysent.c Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/amd64/linux32/linux32_sysent.c Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #include "opt_compat.h" @@ -330,4 +330,10 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_pselect6, AUE_NULL, NULL, 0, 0 }, /* 308 = linux_pselect6 */ { 0, (sy_call_t *)linux_ppoll, AUE_NULL, NULL, 0, 0 }, /* 309 = linux_ppoll */ { 0, (sy_call_t *)linux_unshare, AUE_NULL, NULL, 0, 0 }, /* 310 = linux_unshare */ + { 0, (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 }, /* 311 = linux_set_robust_list */ + { 0, (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 }, /* 312 = linux_get_robust_list */ + { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0 }, /* 313 = linux_splice */ + { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0 }, /* 314 = linux_sync_file_range */ + { 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0 }, /* 315 = linux_tee */ + { 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0 }, /* 316 = linux_vmsplice */ }; Modified: stable/7/sys/i386/linux/linux_proto.h ============================================================================== --- stable/7/sys/i386/linux/linux_proto.h Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/i386/linux/linux_proto.h Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #ifndef _LINUX_SYSPROTO_H_ @@ -955,6 +955,24 @@ struct linux_ppoll_args { struct linux_unshare_args { register_t dummy; }; +struct linux_set_robust_list_args { + register_t dummy; +}; +struct linux_get_robust_list_args { + register_t dummy; +}; +struct linux_splice_args { + register_t dummy; +}; +struct linux_sync_file_range_args { + register_t dummy; +}; +struct linux_tee_args { + register_t dummy; +}; +struct linux_vmsplice_args { + register_t dummy; +}; #define nosys linux_nosys int linux_fork(struct thread *, struct linux_fork_args *); int linux_open(struct thread *, struct linux_open_args *); @@ -1192,6 +1210,12 @@ int linux_faccessat(struct thread *, str int linux_pselect6(struct thread *, struct linux_pselect6_args *); int linux_ppoll(struct thread *, struct linux_ppoll_args *); int linux_unshare(struct thread *, struct linux_unshare_args *); +int linux_set_robust_list(struct thread *, struct linux_set_robust_list_args *); +int linux_get_robust_list(struct thread *, struct linux_get_robust_list_args *); +int linux_splice(struct thread *, struct linux_splice_args *); +int linux_sync_file_range(struct thread *, struct linux_sync_file_range_args *); +int linux_tee(struct thread *, struct linux_tee_args *); +int linux_vmsplice(struct thread *, struct linux_vmsplice_args *); #ifdef COMPAT_43 @@ -1449,6 +1473,12 @@ int linux_unshare(struct thread *, struc #define LINUX_SYS_AUE_linux_pselect6 AUE_NULL #define LINUX_SYS_AUE_linux_ppoll AUE_NULL #define LINUX_SYS_AUE_linux_unshare AUE_NULL +#define LINUX_SYS_AUE_linux_set_robust_list AUE_NULL +#define LINUX_SYS_AUE_linux_get_robust_list AUE_NULL +#define LINUX_SYS_AUE_linux_splice AUE_NULL +#define LINUX_SYS_AUE_linux_sync_file_range AUE_NULL +#define LINUX_SYS_AUE_linux_tee AUE_NULL +#define LINUX_SYS_AUE_linux_vmsplice AUE_NULL #undef PAD_ #undef PADL_ Modified: stable/7/sys/i386/linux/linux_syscall.h ============================================================================== --- stable/7/sys/i386/linux/linux_syscall.h Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/i386/linux/linux_syscall.h Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #define LINUX_SYS_exit 1 @@ -290,4 +290,10 @@ #define LINUX_SYS_linux_pselect6 308 #define LINUX_SYS_linux_ppoll 309 #define LINUX_SYS_linux_unshare 310 -#define LINUX_SYS_MAXSYSCALL 311 +#define LINUX_SYS_linux_set_robust_list 311 +#define LINUX_SYS_linux_get_robust_list 312 +#define LINUX_SYS_linux_splice 313 +#define LINUX_SYS_linux_sync_file_range 314 +#define LINUX_SYS_linux_tee 315 +#define LINUX_SYS_linux_vmsplice 316 +#define LINUX_SYS_MAXSYSCALL 317 Modified: stable/7/sys/i386/linux/linux_sysent.c ============================================================================== --- stable/7/sys/i386/linux/linux_sysent.c Tue May 5 03:49:30 2009 (r191804) +++ stable/7/sys/i386/linux/linux_sysent.c Tue May 5 03:51:41 2009 (r191805) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 184075 2008-10-20 11:15:57Z kib + * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin */ #include @@ -329,4 +329,10 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_pselect6, AUE_NULL, NULL, 0, 0 }, /* 308 = linux_pselect6 */ { 0, (sy_call_t *)linux_ppoll, AUE_NULL, NULL, 0, 0 }, /* 309 = linux_ppoll */ { 0, (sy_call_t *)linux_unshare, AUE_NULL, NULL, 0, 0 }, /* 310 = linux_unshare */ + { 0, (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 }, /* 311 = linux_set_robust_list */ + { 0, (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 }, /* 312 = linux_get_robust_list */ + { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0 }, /* 313 = linux_splice */ + { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0 }, /* 314 = linux_sync_file_range */ + { 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0 }, /* 315 = linux_tee */ + { 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0 }, /* 316 = linux_vmsplice */ }; From owner-svn-src-stable-7@FreeBSD.ORG Tue May 5 07:05:13 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 752C91065670; Tue, 5 May 2009 07:05: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 56CDD8FC24; Tue, 5 May 2009 07:05:13 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4575DNH070168; Tue, 5 May 2009 07:05:13 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4575Dtk070167; Tue, 5 May 2009 07:05:13 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200905050705.n4575Dtk070167@svn.freebsd.org> From: Edwin Groothuis Date: Tue, 5 May 2009 07:05: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: r191807 - stable/7/share/zoneinfo X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2009 07:05:14 -0000 Author: edwin Date: Tue May 5 07:05:13 2009 New Revision: 191807 URL: http://svn.freebsd.org/changeset/base/191807 Log: MFC of tzdata2009g: Egypt will have DST till the end of September the coming years. Modified: stable/7/share/zoneinfo/ (props changed) stable/7/share/zoneinfo/africa Modified: stable/7/share/zoneinfo/africa ============================================================================== --- stable/7/share/zoneinfo/africa Tue May 5 05:49:08 2009 (r191806) +++ stable/7/share/zoneinfo/africa Tue May 5 07:05:13 2009 (r191807) @@ -1,4 +1,4 @@ -# @(#)africa 8.18 +# @(#)africa 8.19 #
 
 # This data is by no means authoritative; if you think you know better,
@@ -236,7 +236,46 @@ Rule	Egypt	2007	only	-	Sep	Thu>=1	23:00s
 # unless discontinued, next DST may end Thursday 28 August 2008.
 # From Paul Eggert (2007-08-17):
 # For lack of better info, assume the new rule is last Thursday in August.
-Rule	Egypt	2008	max	-	Aug	lastThu	23:00s	0	-
+
+# From Petr Machata (2009-04-06):
+# The following appeared in Red Hat bugzilla[1] (edited):
+#
+# > $ zdump -v /usr/share/zoneinfo/Africa/Cairo | grep 2009
+# > /usr/share/zoneinfo/Africa/Cairo  Thu Apr 23 21:59:59 2009 UTC =3D Thu =
+# Apr 23
+# > 23:59:59 2009 EET isdst=3D0 gmtoff=3D7200
+# > /usr/share/zoneinfo/Africa/Cairo  Thu Apr 23 22:00:00 2009 UTC =3D Fri =
+# Apr 24
+# > 01:00:00 2009 EEST isdst=3D1 gmtoff=3D10800
+# > /usr/share/zoneinfo/Africa/Cairo  Thu Aug 27 20:59:59 2009 UTC =3D Thu =
+# Aug 27
+# > 23:59:59 2009 EEST isdst=3D1 gmtoff=3D10800
+# > /usr/share/zoneinfo/Africa/Cairo  Thu Aug 27 21:00:00 2009 UTC =3D Thu =
+# Aug 27
+# > 23:00:00 2009 EET isdst=3D0 gmtoff=3D7200
+#
+# > end date should be Thu Sep 24 2009 (Last Thursday in September at 23:59=
+# :59)
+# > http://support.microsoft.com/kb/958729/
+#
+# timeanddate[2] and another site I've found[3] also support that.
+#
+# [1] 
+# https://bugzilla.redhat.com/show_bug.cgi?id=3D492263
+# 
+# [2] 
+# http://www.timeanddate.com/worldclock/clockchange.html?n=3D53
+# 
+# [3] 
+# http://wwp.greenwichmeantime.com/time-zone/africa/egypt/
+# 
+
+# From Arthur David Olson (2009-04-20):
+# In 2009 (and for the next several years), Ramadan ends before the fourth
+# Thursday in September; Egypt is expected to revert to the last Thursday
+# in September.
+Rule	Egypt	2008	only	-	Aug	lastThu	23:00s	0	-
+Rule	Egypt	2009	max	-	Sep	lastThu	23:00s	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Cairo	2:05:00 -	LMT	1900 Oct

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 09:08:37 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C4A5F106566C;
	Tue,  5 May 2009 09:08:37 +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 B0BDA8FC0C;
	Tue,  5 May 2009 09:08:37 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4598bFF072722;
	Tue, 5 May 2009 09:08:37 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4598bHc072718;
	Tue, 5 May 2009 09:08:37 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905050908.n4598bHc072718@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 09:08:37 +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: r191809 - in stable/7/sys: . amd64/amd64 arm/arm
	contrib/pf dev/ath/ath_hal dev/cxgb i386/i386 ia64/ia64
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 09:08:38 -0000

Author: kib
Date: Tue May  5 09:08:37 2009
New Revision: 191809
URL: http://svn.freebsd.org/changeset/base/191809

Log:
  MFC r191011:
  The bus_dmamap_load_uio(9) shall use pmap of the thread recorded in the
  uio_td to extract pages from, instead of unconditionally use kernel
  pmap.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/busdma_machdep.c
  stable/7/sys/arm/arm/busdma_machdep.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/i386/i386/busdma_machdep.c
  stable/7/sys/ia64/ia64/busdma_machdep.c

Modified: stable/7/sys/amd64/amd64/busdma_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/busdma_machdep.c	Tue May  5 08:30:38 2009	(r191808)
+++ stable/7/sys/amd64/amd64/busdma_machdep.c	Tue May  5 09:08:37 2009	(r191809)
@@ -602,7 +602,10 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
 		vendaddr = (vm_offset_t)buf + buflen;
 
 		while (vaddr < vendaddr) {
-			paddr = pmap_kextract(vaddr);
+			if (pmap)
+				paddr = pmap_extract(pmap, vaddr);
+			else
+				paddr = pmap_kextract(vaddr);
 			if (run_filter(dmat, paddr) != 0)
 				map->pagesneeded++;
 			vaddr += PAGE_SIZE;

Modified: stable/7/sys/arm/arm/busdma_machdep.c
==============================================================================
--- stable/7/sys/arm/arm/busdma_machdep.c	Tue May  5 08:30:38 2009	(r191808)
+++ stable/7/sys/arm/arm/busdma_machdep.c	Tue May  5 09:08:37 2009	(r191809)
@@ -663,8 +663,8 @@ bus_dmamem_free(bus_dma_tag_t dmat, void
 }
 
 static int
-_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
-			bus_size_t buflen, int flags)
+_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
+    void *buf, bus_size_t buflen, int flags)
 {
 	vm_offset_t vaddr;
 	vm_offset_t vendaddr;
@@ -683,7 +683,10 @@ _bus_dmamap_count_pages(bus_dma_tag_t dm
 		vendaddr = (vm_offset_t)buf + buflen;
 
 		while (vaddr < vendaddr) {
-			paddr = pmap_kextract(vaddr);
+			if (pmap != NULL)
+				paddr = pmap_extract(pmap, vaddr);
+			else
+				paddr = pmap_kextract(vaddr);
 			if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) &&
 			    run_filter(dmat, paddr) != 0)
 				map->pagesneeded++;
@@ -739,7 +742,8 @@ bus_dmamap_load_buffer(bus_dma_tag_t dma
 	bmask = ~(dmat->boundary - 1);
 
 	if ((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) {
-		error = _bus_dmamap_count_pages(dmat, map, buf, buflen, flags);
+		error = _bus_dmamap_count_pages(dmat, map, pmap, buf, buflen,
+		    flags);
 		if (error)
 			return (error);
 	}

Modified: stable/7/sys/i386/i386/busdma_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/busdma_machdep.c	Tue May  5 08:30:38 2009	(r191808)
+++ stable/7/sys/i386/i386/busdma_machdep.c	Tue May  5 09:08:37 2009	(r191809)
@@ -141,8 +141,8 @@ static bus_addr_t add_bounce_page(bus_dm
 				   vm_offset_t vaddr, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
 int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
-int _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
-			    bus_size_t buflen, int flags);
+int _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
+    void *buf, bus_size_t buflen, int flags);
 
 /*
  * Return true if a match is made.
@@ -568,8 +568,8 @@ bus_dmamem_free(bus_dma_tag_t dmat, void
 }
 
 int
-_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
-			bus_size_t buflen, int flags)
+_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
+    void *buf, bus_size_t buflen, int flags)
 {
 	vm_offset_t vaddr;
 	vm_offset_t vendaddr;
@@ -589,7 +589,10 @@ _bus_dmamap_count_pages(bus_dma_tag_t dm
 		vendaddr = (vm_offset_t)buf + buflen;
 
 		while (vaddr < vendaddr) {
-			paddr = pmap_kextract(vaddr);
+			if (pmap)
+				paddr = pmap_extract(pmap, vaddr);
+			else
+				paddr = pmap_kextract(vaddr);
 			if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) &&
 			    run_filter(dmat, paddr) != 0) {
 				map->pagesneeded++;
@@ -651,7 +654,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
 		map = &nobounce_dmamap;
 
 	if ((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) {
-		error = _bus_dmamap_count_pages(dmat, map, buf, buflen, flags);
+		error = _bus_dmamap_count_pages(dmat, map, pmap, buf, buflen, flags);
 		if (error)
 			return (error);
 	}

Modified: stable/7/sys/ia64/ia64/busdma_machdep.c
==============================================================================
--- stable/7/sys/ia64/ia64/busdma_machdep.c	Tue May  5 08:30:38 2009	(r191808)
+++ stable/7/sys/ia64/ia64/busdma_machdep.c	Tue May  5 09:08:37 2009	(r191809)
@@ -527,7 +527,10 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
 		vendaddr = (vm_offset_t)buf + buflen;
 
 		while (vaddr < vendaddr) {
-			paddr = pmap_kextract(vaddr);
+			if (pmap != NULL)
+				paddr = pmap_extract(pmap, vaddr);
+			else
+				paddr = pmap_kextract(vaddr);
 			if (run_filter(dmat, paddr, 0) != 0)
 				map->pagesneeded++;
 			vaddr += PAGE_SIZE;

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 09:16:57 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF2631065670;
	Tue,  5 May 2009 09:16:57 +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 A240A8FC0C;
	Tue,  5 May 2009 09:16:57 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n459GvMZ072941;
	Tue, 5 May 2009 09:16:57 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n459GvbI072939;
	Tue, 5 May 2009 09:16:57 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905050916.n459GvbI072939@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 09:16: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: r191810 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb vm
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 09:16:58 -0000

Author: kib
Date: Tue May  5 09:16:57 2009
New Revision: 191810
URL: http://svn.freebsd.org/changeset/base/191810

Log:
  MFC r190886:
  When vm_map_wire(9) is allowed to skip holes in the wired region, skip
  the mappings without any of read and execution rights, in particular,
  the PROT_NONE entries. This makes mlockall(2) work for the process
  address space that has such mappings.
  
  Since protection mode of the entry may change between setting
  MAP_ENTRY_IN_TRANSITION and final pass over the region that records
  the wire status of the entries, allocate new map entry flag
  MAP_ENTRY_WIRE_SKIPPED to mark the skipped PROT_NONE entries.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/vm/vm_map.c
  stable/7/sys/vm/vm_map.h

Modified: stable/7/sys/vm/vm_map.c
==============================================================================
--- stable/7/sys/vm/vm_map.c	Tue May  5 09:08:37 2009	(r191809)
+++ stable/7/sys/vm/vm_map.c	Tue May  5 09:16:57 2009	(r191810)
@@ -2059,6 +2059,16 @@ vm_map_wire(vm_map_t map, vm_offset_t st
 		 *
 		 */
 		if (entry->wired_count == 0) {
+			if ((entry->protection & (VM_PROT_READ|VM_PROT_EXECUTE))
+			    == 0) {
+				if ((flags & VM_MAP_WIRE_HOLESOK) == 0) {
+					end = entry->end;
+					rv = KERN_INVALID_ADDRESS;
+					goto done;
+				}
+				entry->eflags |= MAP_ENTRY_WIRE_SKIPPED;
+				goto next_entry;
+			}
 			entry->wired_count++;
 			saved_start = entry->start;
 			saved_end = entry->end;
@@ -2116,6 +2126,7 @@ vm_map_wire(vm_map_t map, vm_offset_t st
 		 * Check the map for holes in the specified region.
 		 * If VM_MAP_WIRE_HOLESOK was specified, skip this check.
 		 */
+	next_entry:
 		if (((flags & VM_MAP_WIRE_HOLESOK) == 0) &&
 		    (entry->end < end && (entry->next == &map->header ||
 		    entry->next->start > entry->end))) {
@@ -2137,6 +2148,8 @@ done:
 	}
 	entry = first_entry;
 	while (entry != &map->header && entry->start < end) {
+		if ((entry->eflags & MAP_ENTRY_WIRE_SKIPPED) != 0)
+			goto next_entry_done;
 		if (rv == KERN_SUCCESS) {
 			if (user_wire)
 				entry->eflags |= MAP_ENTRY_USER_WIRED;
@@ -2159,9 +2172,10 @@ done:
 				    entry->object.vm_object->type == OBJT_DEVICE);
 			}
 		}
+	next_entry_done:
 		KASSERT(entry->eflags & MAP_ENTRY_IN_TRANSITION,
 			("vm_map_wire: in-transition flag missing"));
-		entry->eflags &= ~MAP_ENTRY_IN_TRANSITION;
+		entry->eflags &= ~(MAP_ENTRY_IN_TRANSITION|MAP_ENTRY_WIRE_SKIPPED);
 		if (entry->eflags & MAP_ENTRY_NEEDS_WAKEUP) {
 			entry->eflags &= ~MAP_ENTRY_NEEDS_WAKEUP;
 			need_wakeup = TRUE;

Modified: stable/7/sys/vm/vm_map.h
==============================================================================
--- stable/7/sys/vm/vm_map.h	Tue May  5 09:08:37 2009	(r191809)
+++ stable/7/sys/vm/vm_map.h	Tue May  5 09:16:57 2009	(r191810)
@@ -138,6 +138,8 @@ struct vm_map_entry {
 #define	MAP_ENTRY_GROWS_DOWN		0x1000	/* Top-down stacks */
 #define	MAP_ENTRY_GROWS_UP		0x2000	/* Bottom-up stacks */
 
+#define	MAP_ENTRY_WIRE_SKIPPED		0x4000
+
 #ifdef	_KERNEL
 static __inline u_char
 vm_map_entry_behavior(vm_map_entry_t entry)

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 09:20:08 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 286A6106564A;
	Tue,  5 May 2009 09:20:08 +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 CB6A78FC2D;
	Tue,  5 May 2009 09:20:07 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n459K7ue073053;
	Tue, 5 May 2009 09:20:07 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n459K7Tg073052;
	Tue, 5 May 2009 09:20:07 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905050920.n459K7Tg073052@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 09:20:07 +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: r191811 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb ufs/ffs
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 09:20:09 -0000

Author: kib
Date: Tue May  5 09:20:07 2009
New Revision: 191811
URL: http://svn.freebsd.org/changeset/base/191811

Log:
  MFC r190690:
  When removing or renaming snaphost, do not delve into request_cleanup().
  The later may need blocks from the underlying device that belongs
  to normal files, that should not be locked while snap lock is held.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/ufs/ffs/ffs_softdep.c

Modified: stable/7/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- stable/7/sys/ufs/ffs/ffs_softdep.c	Tue May  5 09:16:57 2009	(r191810)
+++ stable/7/sys/ufs/ffs/ffs_softdep.c	Tue May  5 09:20:07 2009	(r191811)
@@ -3315,7 +3315,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirre
 	 * the number of freefile and freeblks structures.
 	 */
 	ACQUIRE_LOCK(&lk);
-	if (num_dirrem > max_softdeps / 2)
+	if (!(ip->i_flags & SF_SNAPSHOT) && num_dirrem > max_softdeps / 2)
 		(void) request_cleanup(ITOV(dp)->v_mount, FLUSH_REMOVE);
 	num_dirrem += 1;
 	FREE_LOCK(&lk);

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 09:24:20 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9B811106566B;
	Tue,  5 May 2009 09:24:20 +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 88A3C8FC18;
	Tue,  5 May 2009 09:24:20 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n459OKV0073194;
	Tue, 5 May 2009 09:24:20 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n459OK2f073193;
	Tue, 5 May 2009 09:24:20 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905050924.n459OK2f073193@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 09:24:20 +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: r191812 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb kern
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 09:24:21 -0000

Author: kib
Date: Tue May  5 09:24:20 2009
New Revision: 191812
URL: http://svn.freebsd.org/changeset/base/191812

Log:
  MFC r191313:
  On the exit of the child process which parent either set SA_NOCLDWAIT
  or ignored SIGCHLD, unconditionally wake up the parent instead of doing
  this only when the child is a last child.
  
  MFC r191319:
  Fix typo.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/kern/kern_exit.c

Modified: stable/7/sys/kern/kern_exit.c
==============================================================================
--- stable/7/sys/kern/kern_exit.c	Tue May  5 09:20:07 2009	(r191811)
+++ stable/7/sys/kern/kern_exit.c	Tue May  5 09:24:20 2009	(r191812)
@@ -511,13 +511,13 @@ retry:
 		proc_reparent(p, initproc);
 		p->p_sigparent = SIGCHLD;
 		PROC_LOCK(p->p_pptr);
+
 		/*
-		 * If this was the last child of our parent, notify
-		 * parent, so in case he was wait(2)ing, he will
+		 * Notify parent, so in case he was wait(2)ing or
+		 * executing waitpid(2) with our pid, he will
 		 * continue.
 		 */
-		if (LIST_EMPTY(&pp->p_children))
-			wakeup(pp);
+		wakeup(pp);
 	} else
 		mtx_unlock(&p->p_pptr->p_sigacts->ps_mtx);
 

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 10:34:44 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 584F51065670;
	Tue,  5 May 2009 10:34:44 +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 42BD68FC0C;
	Tue,  5 May 2009 10:34:44 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45AYi2D074741;
	Tue, 5 May 2009 10:34:44 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45AYild074736;
	Tue, 5 May 2009 10:34:44 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905051034.n45AYild074736@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 10:34:44 +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: r191813 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb gnu/fs/xfs/FreeBSD kern sys ufs/ffs
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 10:34:44 -0000

Author: kib
Date: Tue May  5 10:34:43 2009
New Revision: 191813
URL: http://svn.freebsd.org/changeset/base/191813

Log:
  MFC r189878:
  Fix two issues with bufdaemon, often causing the processes to hang in
  the "nbufkv" sleep.
  
  Do not retry request for the new block from ffs_bufwrite() when write is done
  from bufdaemon and there is a buffer shortage.
  
  In getnewbuf(), help bufdaemon to flush dirty buffers owned by the vnode
  locked by curthread.
  
  For MFC, default value for sysctl vfs.flushbufqtarget is set to -1,
  disabling the helpers. The TDP_BUFNEED flag value from HEAD conflicts
  with TDP_UPCALLING KSE bit, so it is moved to the end of allocated bits.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c
  stable/7/sys/kern/vfs_bio.c
  stable/7/sys/sys/buf.h
  stable/7/sys/sys/proc.h
  stable/7/sys/ufs/ffs/ffs_vfsops.c

Modified: stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c
==============================================================================
--- stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c	Tue May  5 09:24:20 2009	(r191812)
+++ stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c	Tue May  5 10:34:43 2009	(r191813)
@@ -81,7 +81,7 @@ xfs_buf_get_empty(size_t size,  xfs_buft
 {
 	struct buf *bp;
 
-	bp = geteblk(0);
+	bp = geteblk(0, 0);
 	if (bp != NULL) {
 		bp->b_bufsize = size;
 		bp->b_bcount = size;
@@ -101,7 +101,7 @@ xfs_buf_get_noaddr(size_t len, xfs_bufta
 	if (len >= MAXPHYS)
 		return (NULL);
 
-	bp = geteblk(len);
+	bp = geteblk(len, 0);
 	if (bp != NULL) {
 		KASSERT(BUF_REFCNT(bp) == 1,
 			("xfs_buf_get_empty: bp %p not locked",bp));

Modified: stable/7/sys/kern/vfs_bio.c
==============================================================================
--- stable/7/sys/kern/vfs_bio.c	Tue May  5 09:24:20 2009	(r191812)
+++ stable/7/sys/kern/vfs_bio.c	Tue May  5 10:34:43 2009	(r191813)
@@ -105,7 +105,8 @@ static void vfs_setdirty_locked_object(s
 static void vfs_vmio_release(struct buf *bp);
 static int vfs_bio_clcheck(struct vnode *vp, int size,
 		daddr_t lblkno, daddr_t blkno);
-static int flushbufqueues(int, int);
+static int buf_do_flush(struct vnode *vp);
+static int flushbufqueues(struct vnode *, int, int);
 static void buf_daemon(void);
 static void bremfreel(struct buf *bp);
 
@@ -187,6 +188,9 @@ SYSCTL_INT(_vfs, OID_AUTO, getnewbufcall
 static int getnewbufrestarts;
 SYSCTL_INT(_vfs, OID_AUTO, getnewbufrestarts, CTLFLAG_RW, &getnewbufrestarts, 0,
     "Number of times getnewbuf has had to restart a buffer aquisition");
+static int flushbufqtarget = -1;
+SYSCTL_INT(_vfs, OID_AUTO, flushbufqtarget, CTLFLAG_RW, &flushbufqtarget, 0,
+    "Amount of work to do in flushbufqueues when helping bufdaemon");
 
 /*
  * Wakeup point for bufdaemon, as well as indicator of whether it is already
@@ -258,6 +262,7 @@ static struct mtx bpinlock;
 #define QUEUE_DIRTY_GIANT 3	/* B_DELWRI buffers that need giant */
 #define QUEUE_EMPTYKVA	4	/* empty buffer headers w/KVA assignment */
 #define QUEUE_EMPTY	5	/* empty buffer headers */
+#define QUEUE_SENTINEL	1024	/* not an queue index, but mark for sentinel */
 
 /* Queues for free buffers with various properties */
 static TAILQ_HEAD(bqueues, buf) bufqueues[BUFFER_QUEUES] = { { 0 } };
@@ -1707,21 +1712,23 @@ vfs_bio_awrite(struct buf *bp)
  */
 
 static struct buf *
-getnewbuf(int slpflag, int slptimeo, int size, int maxsize)
+getnewbuf(struct vnode *vp, int slpflag, int slptimeo, int size, int maxsize,
+    int gbflags)
 {
+	struct thread *td;
 	struct buf *bp;
 	struct buf *nbp;
 	int defrag = 0;
 	int nqindex;
 	static int flushingbufs;
 
+	td = curthread;
 	/*
 	 * We can't afford to block since we might be holding a vnode lock,
 	 * which may prevent system daemons from running.  We deal with
 	 * low-memory situations by proactively returning memory and running
 	 * async I/O rather then sync I/O.
 	 */
-
 	atomic_add_int(&getnewbufcalls, 1);
 	atomic_subtract_int(&getnewbufrestarts, 1);
 restart:
@@ -1953,8 +1960,9 @@ restart:
 	 */
 
 	if (bp == NULL) {
-		int flags;
+		int flags, norunbuf;
 		char *waitmsg;
+		int fl;
 
 		if (defrag) {
 			flags = VFS_BIO_NEED_BUFSPACE;
@@ -1972,9 +1980,35 @@ restart:
 		mtx_unlock(&bqlock);
 
 		bd_speedup();	/* heeeelp */
+		if (gbflags & GB_NOWAIT_BD)
+			return (NULL);
 
 		mtx_lock(&nblock);
 		while (needsbuffer & flags) {
+			if (vp != NULL && (td->td_pflags & TDP_BUFNEED) == 0) {
+				mtx_unlock(&nblock);
+				/*
+				 * getblk() is called with a vnode
+				 * locked, and some majority of the
+				 * dirty buffers may as well belong to
+				 * the vnode. Flushing the buffers
+				 * there would make a progress that
+				 * cannot be achieved by the
+				 * buf_daemon, that cannot lock the
+				 * vnode.
+				 */
+				norunbuf = ~(TDP_BUFNEED | TDP_NORUNNINGBUF) |
+				    (td->td_pflags & TDP_NORUNNINGBUF);
+				/* play bufdaemon */
+				td->td_pflags |= TDP_BUFNEED | TDP_NORUNNINGBUF;
+				fl = buf_do_flush(vp);
+				td->td_pflags &= norunbuf;
+				mtx_lock(&nblock);
+				if (fl != 0)
+					continue;
+				if ((needsbuffer & flags) == 0)
+					break;
+			}
 			if (msleep(&needsbuffer, &nblock,
 			    (PRIBIO + 4) | slpflag, waitmsg, slptimeo)) {
 				mtx_unlock(&nblock);
@@ -2043,6 +2077,35 @@ static struct kproc_desc buf_kp = {
 };
 SYSINIT(bufdaemon, SI_SUB_KTHREAD_BUF, SI_ORDER_FIRST, kproc_start, &buf_kp);
 
+static int
+buf_do_flush(struct vnode *vp)
+{
+	int flushed;
+
+	flushed = flushbufqueues(vp, QUEUE_DIRTY, 0);
+	/* The list empty check here is slightly racy */
+	if (!TAILQ_EMPTY(&bufqueues[QUEUE_DIRTY_GIANT])) {
+		mtx_lock(&Giant);
+		flushed += flushbufqueues(vp, QUEUE_DIRTY_GIANT, 0);
+		mtx_unlock(&Giant);
+	}
+	if (flushed == 0) {
+		/*
+		 * Could not find any buffers without rollback
+		 * dependencies, so just write the first one
+		 * in the hopes of eventually making progress.
+		 */
+		flushbufqueues(vp, QUEUE_DIRTY, 1);
+		if (!TAILQ_EMPTY(
+			    &bufqueues[QUEUE_DIRTY_GIANT])) {
+			mtx_lock(&Giant);
+			flushbufqueues(vp, QUEUE_DIRTY_GIANT, 1);
+			mtx_unlock(&Giant);
+		}
+	}
+	return (flushed);
+}
+
 static void
 buf_daemon()
 {
@@ -2056,7 +2119,7 @@ buf_daemon()
 	/*
 	 * This process is allowed to take the buffer cache to the limit
 	 */
-	curthread->td_pflags |= TDP_NORUNNINGBUF;
+	curthread->td_pflags |= TDP_NORUNNINGBUF | TDP_BUFNEED;
 	mtx_lock(&bdlock);
 	for (;;) {
 		bd_request = 0;
@@ -2071,30 +2134,8 @@ buf_daemon()
 		 * normally would so they can run in parallel with our drain.
 		 */
 		while (numdirtybuffers > lodirtybuffers) {
-			int flushed;
-
-			flushed = flushbufqueues(QUEUE_DIRTY, 0);
-			/* The list empty check here is slightly racy */
-			if (!TAILQ_EMPTY(&bufqueues[QUEUE_DIRTY_GIANT])) {
-				mtx_lock(&Giant);
-				flushed += flushbufqueues(QUEUE_DIRTY_GIANT, 0);
-				mtx_unlock(&Giant);
-			}
-			if (flushed == 0) {
-				/*
-				 * Could not find any buffers without rollback
-				 * dependencies, so just write the first one
-				 * in the hopes of eventually making progress.
-				 */
-				flushbufqueues(QUEUE_DIRTY, 1);
-				if (!TAILQ_EMPTY(
-				    &bufqueues[QUEUE_DIRTY_GIANT])) {
-					mtx_lock(&Giant);
-					flushbufqueues(QUEUE_DIRTY_GIANT, 1);
-					mtx_unlock(&Giant);
-				}
+			if (buf_do_flush(NULL) == 0)
 				break;
-			}
 			uio_yield();
 		}
 
@@ -2140,7 +2181,7 @@ SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps
     0, "Number of buffers flushed with dependecies that require rollbacks");
 
 static int
-flushbufqueues(int queue, int flushdeps)
+flushbufqueues(struct vnode *lvp, int queue, int flushdeps)
 {
 	struct thread *td = curthread;
 	struct buf sentinel;
@@ -2151,20 +2192,37 @@ flushbufqueues(int queue, int flushdeps)
 	int flushed;
 	int target;
 
-	target = numdirtybuffers - lodirtybuffers;
-	if (flushdeps && target > 2)
-		target /= 2;
+	if (lvp == NULL) {
+		target = numdirtybuffers - lodirtybuffers;
+		if (flushdeps && target > 2)
+			target /= 2;
+	} else
+		target = flushbufqtarget;
 	flushed = 0;
 	bp = NULL;
+	sentinel.b_qindex = QUEUE_SENTINEL;
 	mtx_lock(&bqlock);
-	TAILQ_INSERT_TAIL(&bufqueues[queue], &sentinel, b_freelist);
+	TAILQ_INSERT_HEAD(&bufqueues[queue], &sentinel, b_freelist);
 	while (flushed != target) {
-		bp = TAILQ_FIRST(&bufqueues[queue]);
-		if (bp == &sentinel)
+		bp = TAILQ_NEXT(&sentinel, b_freelist);
+		if (bp != NULL) {
+			TAILQ_REMOVE(&bufqueues[queue], &sentinel, b_freelist);
+			TAILQ_INSERT_AFTER(&bufqueues[queue], bp, &sentinel,
+			    b_freelist);
+		} else
 			break;
-		TAILQ_REMOVE(&bufqueues[queue], bp, b_freelist);
-		TAILQ_INSERT_TAIL(&bufqueues[queue], bp, b_freelist);
-
+		/*
+		 * Skip sentinels inserted by other invocations of the
+		 * flushbufqueues(), taking care to not reorder them.
+		 */
+		if (bp->b_qindex == QUEUE_SENTINEL)
+			continue;
+		/*
+		 * Only flush the buffers that belong to the
+		 * vnode locked by the curthread.
+		 */
+		if (lvp != NULL && bp->b_vp != lvp)
+			continue;
 		if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) != 0)
 			continue;
 		if (bp->b_pin_count > 0) {
@@ -2212,16 +2270,28 @@ flushbufqueues(int queue, int flushdeps)
 			BUF_UNLOCK(bp);
 			continue;
 		}
-		if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT, td) == 0) {
+		if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_CANRECURSE,
+		    td) == 0) {
 			mtx_unlock(&bqlock);
 			CTR3(KTR_BUF, "flushbufqueue(%p) vp %p flags %X",
 			    bp, bp->b_vp, bp->b_flags);
-			vfs_bio_awrite(bp);
+			if (curproc == bufdaemonproc)
+				vfs_bio_awrite(bp);
+			else {
+				bremfree(bp);
+				bwrite(bp);
+			}
 			vn_finished_write(mp);
 			VOP_UNLOCK(vp, 0, td);
 			flushwithdeps += hasdeps;
 			flushed++;
-			waitrunningbufspace();
+
+			/*
+			 * Sleeping on runningbufspace while holding
+			 * vnode lock leads to deadlock.
+			 */
+			if (curproc == bufdaemonproc)
+				waitrunningbufspace();
 			numdirtywakeup((lodirtybuffers + hidirtybuffers) / 2);
 			mtx_lock(&bqlock);
 			continue;
@@ -2603,7 +2673,7 @@ loop:
 		maxsize = vmio ? size + (offset & PAGE_MASK) : size;
 		maxsize = imax(maxsize, bsize);
 
-		bp = getnewbuf(slpflag, slptimeo, size, maxsize);
+		bp = getnewbuf(vp, slpflag, slptimeo, size, maxsize, flags);
 		if (bp == NULL) {
 			if (slpflag || slptimeo)
 				return NULL;
@@ -2678,14 +2748,17 @@ loop:
  * set to B_INVAL.
  */
 struct buf *
-geteblk(int size)
+geteblk(int size, int flags)
 {
 	struct buf *bp;
 	int maxsize;
 
 	maxsize = (size + BKVAMASK) & ~BKVAMASK;
-	while ((bp = getnewbuf(0, 0, size, maxsize)) == 0)
-		continue;
+	while ((bp = getnewbuf(NULL, 0, 0, size, maxsize, flags)) == NULL) {
+		if ((flags & GB_NOWAIT_BD) &&
+		    (curthread->td_pflags & TDP_BUFNEED) != 0)
+			return (NULL);
+	}
 	allocbuf(bp, size);
 	bp->b_flags |= B_INVAL;	/* b_dep cleared by getnewbuf() */
 	KASSERT(BUF_REFCNT(bp) == 1, ("geteblk: bp %p not locked",bp));

Modified: stable/7/sys/sys/buf.h
==============================================================================
--- stable/7/sys/sys/buf.h	Tue May  5 09:24:20 2009	(r191812)
+++ stable/7/sys/sys/buf.h	Tue May  5 10:34:43 2009	(r191813)
@@ -475,6 +475,7 @@ buf_countdeps(struct buf *bp, int i)
  */
 #define	GB_LOCK_NOWAIT	0x0001		/* Fail if we block on a buf lock. */
 #define	GB_NOCREAT	0x0002		/* Don't create a buf if not found. */
+#define	GB_NOWAIT_BD	0x0004		/* Do not wait for bufdaemon */
 
 #ifdef _KERNEL
 extern int	nbuf;			/* The number of buffer headers */
@@ -519,7 +520,7 @@ struct buf *     getpbuf(int *);
 struct buf *incore(struct bufobj *, daddr_t);
 struct buf *gbincore(struct bufobj *, daddr_t);
 struct buf *getblk(struct vnode *, daddr_t, int, int, int, int);
-struct buf *geteblk(int);
+struct buf *geteblk(int, int);
 int	bufwait(struct buf *);
 int	bufwrite(struct buf *);
 void	bufdone(struct buf *);

Modified: stable/7/sys/sys/proc.h
==============================================================================
--- stable/7/sys/sys/proc.h	Tue May  5 09:24:20 2009	(r191812)
+++ stable/7/sys/sys/proc.h	Tue May  5 10:34:43 2009	(r191813)
@@ -380,6 +380,7 @@ do {									\
 #define	TDP_INBDFLUSH	0x00100000 /* Already in BO_BDFLUSH, do not recurse */
 #define	TDP_IGNSUSP	0x00800000 /* Permission to ignore the MNTK_SUSPEND* */
 #define	TDP_AUDITREC	0x01000000 /* Audit record pending on thread */
+#define	TDP_BUFNEED	0x02000000 /* Do not recurse into the buf flush */
 
 /*
  * Reasons that the current thread can not be run yet.

Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- stable/7/sys/ufs/ffs/ffs_vfsops.c	Tue May  5 09:24:20 2009	(r191812)
+++ stable/7/sys/ufs/ffs/ffs_vfsops.c	Tue May  5 10:34:43 2009	(r191813)
@@ -1842,7 +1842,9 @@ ffs_bufwrite(struct buf *bp)
 		    ("bufwrite: needs chained iodone (%p)", bp->b_iodone));
 
 		/* get a new block */
-		newbp = geteblk(bp->b_bufsize);
+		newbp = geteblk(bp->b_bufsize, GB_NOWAIT_BD);
+		if (newbp == NULL)
+			goto normal_write;
 
 		/*
 		 * set it to be identical to the old block.  We have to
@@ -1882,6 +1884,7 @@ ffs_bufwrite(struct buf *bp)
 	}
 
 	/* Let the normal bufwrite do the rest for us */
+normal_write:
 	return (bufwrite(bp));
 }
 

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 10:43:14 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8C716106564A;
	Tue,  5 May 2009 10:43:14 +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 787458FC13;
	Tue,  5 May 2009 10:43:14 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45AhE1M078963;
	Tue, 5 May 2009 10:43:14 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45AhE9E078962;
	Tue, 5 May 2009 10:43:14 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905051043.n45AhE9E078962@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 10:43:14 +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: r191814 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb kern
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 10:43:15 -0000

Author: kib
Date: Tue May  5 10:43:14 2009
New Revision: 191814
URL: http://svn.freebsd.org/changeset/base/191814

Log:
  MFC r191135:
  Export the number of times bufdaemon got help from the normal threads.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/kern/vfs_bio.c

Modified: stable/7/sys/kern/vfs_bio.c
==============================================================================
--- stable/7/sys/kern/vfs_bio.c	Tue May  5 10:34:43 2009	(r191813)
+++ stable/7/sys/kern/vfs_bio.c	Tue May  5 10:43:14 2009	(r191814)
@@ -191,6 +191,9 @@ SYSCTL_INT(_vfs, OID_AUTO, getnewbufrest
 static int flushbufqtarget = -1;
 SYSCTL_INT(_vfs, OID_AUTO, flushbufqtarget, CTLFLAG_RW, &flushbufqtarget, 0,
     "Amount of work to do in flushbufqueues when helping bufdaemon");
+static long notbufdflashes;
+SYSCTL_LONG(_vfs, OID_AUTO, notbufdflashes, CTLFLAG_RD, ¬bufdflashes, 0,
+    "Number of dirty buffer flushes done by the bufdaemon helpers");
 
 /*
  * Wakeup point for bufdaemon, as well as indicator of whether it is already
@@ -2280,6 +2283,7 @@ flushbufqueues(struct vnode *lvp, int qu
 			else {
 				bremfree(bp);
 				bwrite(bp);
+				notbufdflashes++;
 			}
 			vn_finished_write(mp);
 			VOP_UNLOCK(vp, 0, td);

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 10:46:49 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E99AA106567B;
	Tue,  5 May 2009 10:46:49 +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 BAEF38FC17;
	Tue,  5 May 2009 10:46:49 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45Akn6E079095;
	Tue, 5 May 2009 10:46:49 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45Akn7l079094;
	Tue, 5 May 2009 10:46:49 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905051046.n45Akn7l079094@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 5 May 2009 10:46:49 +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: r191815 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb kern
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 10:46:50 -0000

Author: kib
Date: Tue May  5 10:46:49 2009
New Revision: 191815
URL: http://svn.freebsd.org/changeset/base/191815

Log:
  MFC r191136:
  In flushbufqueues(), do not allocate sentinel buffer on the stack,
  struct buf is large. Use sleeping malloc(9) call, and zero the allocated
  buf as a debugging feature.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/kern/vfs_bio.c

Modified: stable/7/sys/kern/vfs_bio.c
==============================================================================
--- stable/7/sys/kern/vfs_bio.c	Tue May  5 10:43:14 2009	(r191814)
+++ stable/7/sys/kern/vfs_bio.c	Tue May  5 10:46:49 2009	(r191815)
@@ -2187,7 +2187,7 @@ static int
 flushbufqueues(struct vnode *lvp, int queue, int flushdeps)
 {
 	struct thread *td = curthread;
-	struct buf sentinel;
+	struct buf *sentinel;
 	struct vnode *vp;
 	struct mount *mp;
 	struct buf *bp;
@@ -2203,14 +2203,15 @@ flushbufqueues(struct vnode *lvp, int qu
 		target = flushbufqtarget;
 	flushed = 0;
 	bp = NULL;
-	sentinel.b_qindex = QUEUE_SENTINEL;
+	sentinel = malloc(sizeof(struct buf), M_TEMP, M_WAITOK | M_ZERO);
+	sentinel->b_qindex = QUEUE_SENTINEL;
 	mtx_lock(&bqlock);
-	TAILQ_INSERT_HEAD(&bufqueues[queue], &sentinel, b_freelist);
+	TAILQ_INSERT_HEAD(&bufqueues[queue], sentinel, b_freelist);
 	while (flushed != target) {
-		bp = TAILQ_NEXT(&sentinel, b_freelist);
+		bp = TAILQ_NEXT(sentinel, b_freelist);
 		if (bp != NULL) {
-			TAILQ_REMOVE(&bufqueues[queue], &sentinel, b_freelist);
-			TAILQ_INSERT_AFTER(&bufqueues[queue], bp, &sentinel,
+			TAILQ_REMOVE(&bufqueues[queue], sentinel, b_freelist);
+			TAILQ_INSERT_AFTER(&bufqueues[queue], bp, sentinel,
 			    b_freelist);
 		} else
 			break;
@@ -2303,8 +2304,9 @@ flushbufqueues(struct vnode *lvp, int qu
 		vn_finished_write(mp);
 		BUF_UNLOCK(bp);
 	}
-	TAILQ_REMOVE(&bufqueues[queue], &sentinel, b_freelist);
+	TAILQ_REMOVE(&bufqueues[queue], sentinel, b_freelist);
 	mtx_unlock(&bqlock);
+	free(sentinel, M_TEMP);
 	return (flushed);
 }
 

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 14:46:18 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AE2881065670;
	Tue,  5 May 2009 14:46:18 +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 9982B8FC1B;
	Tue,  5 May 2009 14:46:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45EkIRI084179;
	Tue, 5 May 2009 14:46:18 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45EkIhZ084178;
	Tue, 5 May 2009 14:46:18 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <200905051446.n45EkIhZ084178@svn.freebsd.org>
From: John Baldwin 
Date: Tue, 5 May 2009 14:46:18 +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: r191819 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb dev/pci
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 14:46:19 -0000

Author: jhb
Date: Tue May  5 14:46:18 2009
New Revision: 191819
URL: http://svn.freebsd.org/changeset/base/191819

Log:
  MFC: Sync with HEAD
  - Proxy PCI MSI/MSI-X requests and bus interrupt requests for child devices
    instead of passing them through directly.  This allows child devices to use
    MSI/MSI-X interrupts.
  - Proxy PCI VPD requests.
  - Proxy bus resource allocation requests to allow multiple child devices to
    share access to a BAR.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/pci/vga_pci.c

Modified: stable/7/sys/dev/pci/vga_pci.c
==============================================================================
--- stable/7/sys/dev/pci/vga_pci.c	Tue May  5 13:48:53 2009	(r191818)
+++ stable/7/sys/dev/pci/vga_pci.c	Tue May  5 14:46:18 2009	(r191819)
@@ -42,10 +42,22 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
 
+struct vga_resource {
+	struct resource	*vr_res;
+	int	vr_refs;
+};
+
+struct vga_pci_softc {
+	device_t	vga_msi_child;	/* Child driver using MSI. */
+	struct vga_resource vga_res[PCIR_MAX_BAR_0 + 1];
+};
+
 static int
 vga_pci_probe(device_t dev)
 {
@@ -106,11 +118,47 @@ vga_pci_write_ivar(device_t dev, device_
 	return (EINVAL);
 }
 
+static int
+vga_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
+    int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg,
+    void **cookiep)
+{
+	return (BUS_SETUP_INTR(device_get_parent(dev), dev, irq, flags,
+	    filter, intr, arg, cookiep));
+}
+
+static int
+vga_pci_teardown_intr(device_t dev, device_t child, struct resource *irq,
+    void *cookie)
+{
+	return (BUS_TEARDOWN_INTR(device_get_parent(dev), dev, irq, cookie));
+}
+
 static struct resource *
 vga_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
 {
+	struct vga_pci_softc *sc;
+	int bar;
 
+	switch (type) {
+	case SYS_RES_MEMORY:
+	case SYS_RES_IOPORT:
+		/*
+		 * For BARs, we cache the resource so that we only allocate it
+		 * from the PCI bus once.
+		 */
+		bar = PCI_RID2BAR(*rid);
+		if (bar < 0 || bar > PCIR_MAX_BAR_0)
+			return (NULL);
+		sc = device_get_softc(dev);
+		if (sc->vga_res[bar].vr_res == NULL)
+			sc->vga_res[bar].vr_res = bus_alloc_resource(dev, type,
+			    rid, start, end, count, flags);
+		if (sc->vga_res[bar].vr_res != NULL)
+			sc->vga_res[bar].vr_refs++;
+		return (sc->vga_res[bar].vr_res);
+	}
 	return (bus_alloc_resource(dev, type, rid, start, end, count, flags));
 }
 
@@ -118,6 +166,37 @@ static int
 vga_pci_release_resource(device_t dev, device_t child, int type, int rid,
     struct resource *r)
 {
+	struct vga_pci_softc *sc;
+	int bar, error;
+
+	switch (type) {
+	case SYS_RES_MEMORY:
+	case SYS_RES_IOPORT:
+		/*
+		 * For BARs, we release the resource from the PCI bus
+		 * when the last child reference goes away.
+		 */
+		bar = PCI_RID2BAR(rid);
+		if (bar < 0 || bar > PCIR_MAX_BAR_0)
+			return (EINVAL);
+		sc = device_get_softc(dev);
+		if (sc->vga_res[bar].vr_res == NULL)
+			return (EINVAL);
+		KASSERT(sc->vga_res[bar].vr_res == r,
+		    ("vga_pci resource mismatch"));
+		if (sc->vga_res[bar].vr_refs > 1) {
+			sc->vga_res[bar].vr_refs--;
+			return (0);
+		}
+		KASSERT(sc->vga_res[bar].vr_refs > 0,
+		    ("vga_pci resource reference count underflow"));
+		error = bus_release_resource(dev, type, rid, r);
+		if (error == 0) {
+			sc->vga_res[bar].vr_res = NULL;
+			sc->vga_res[bar].vr_refs = 0;
+		}
+		return (error);
+	}
 
 	return (bus_release_resource(dev, type, rid, r));
 }
@@ -176,6 +255,21 @@ vga_pci_disable_io(device_t dev, device_
 }
 
 static int
+vga_pci_get_vpd_ident(device_t dev, device_t child, const char **identptr)
+{
+
+	return (pci_get_vpd_ident(dev, identptr));
+}
+
+static int
+vga_pci_get_vpd_readonly(device_t dev, device_t child, const char *kw,
+    const char **vptr)
+{
+
+	return (pci_get_vpd_readonly(dev, kw, vptr));
+}
+
+static int
 vga_pci_set_powerstate(device_t dev, device_t child, int state)
 {
 
@@ -210,6 +304,77 @@ vga_pci_find_extcap(device_t dev, device
 	return (pci_find_extcap(dev, capability, capreg));
 }
 
+static int
+vga_pci_alloc_msi(device_t dev, device_t child, int *count)
+{
+	struct vga_pci_softc *sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	if (sc->vga_msi_child != NULL)
+		return (EBUSY);
+	error = pci_alloc_msi(dev, count);
+	if (error == 0)
+		sc->vga_msi_child = child;
+	return (error);
+}
+
+static int
+vga_pci_alloc_msix(device_t dev, device_t child, int *count)
+{
+	struct vga_pci_softc *sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	if (sc->vga_msi_child != NULL)
+		return (EBUSY);
+	error = pci_alloc_msix(dev, count);
+	if (error == 0)
+		sc->vga_msi_child = child;
+	return (error);
+}
+
+static int
+vga_pci_remap_msix(device_t dev, device_t child, int count,
+    const u_int *vectors)
+{
+	struct vga_pci_softc *sc;
+
+	sc = device_get_softc(dev);
+	if (sc->vga_msi_child != child)
+		return (ENXIO);
+	return (pci_remap_msix(dev, count, vectors));
+}
+
+static int
+vga_pci_release_msi(device_t dev, device_t child)
+{
+	struct vga_pci_softc *sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	if (sc->vga_msi_child != child)
+		return (ENXIO);
+	error = pci_release_msi(dev);
+	if (error == 0)
+		sc->vga_msi_child = NULL;
+	return (error);
+}
+
+static int
+vga_pci_msi_count(device_t dev, device_t child)
+{
+
+	return (pci_msi_count(dev));
+}
+
+static int
+vga_pci_msix_count(device_t dev, device_t child)
+{
+
+	return (pci_msix_count(dev));
+}
+
 static device_method_t vga_pci_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		vga_pci_probe),
@@ -221,8 +386,8 @@ static device_method_t vga_pci_methods[]
 	/* Bus interface */
 	DEVMETHOD(bus_read_ivar,	vga_pci_read_ivar),
 	DEVMETHOD(bus_write_ivar,	vga_pci_write_ivar),
-	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
-	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_setup_intr,	vga_pci_setup_intr),
+	DEVMETHOD(bus_teardown_intr,	vga_pci_teardown_intr),
 
 	DEVMETHOD(bus_alloc_resource,	vga_pci_alloc_resource),
 	DEVMETHOD(bus_release_resource,	vga_pci_release_resource),
@@ -236,10 +401,18 @@ static device_method_t vga_pci_methods[]
 	DEVMETHOD(pci_disable_busmaster, vga_pci_disable_busmaster),
 	DEVMETHOD(pci_enable_io,	vga_pci_enable_io),
 	DEVMETHOD(pci_disable_io,	vga_pci_disable_io),
+	DEVMETHOD(pci_get_vpd_ident,	vga_pci_get_vpd_ident),
+	DEVMETHOD(pci_get_vpd_readonly,	vga_pci_get_vpd_readonly),
 	DEVMETHOD(pci_get_powerstate,	vga_pci_get_powerstate),
 	DEVMETHOD(pci_set_powerstate,	vga_pci_set_powerstate),
 	DEVMETHOD(pci_assign_interrupt,	vga_pci_assign_interrupt),
 	DEVMETHOD(pci_find_extcap,	vga_pci_find_extcap),
+	DEVMETHOD(pci_alloc_msi,	vga_pci_alloc_msi),
+	DEVMETHOD(pci_alloc_msix,	vga_pci_alloc_msix),
+	DEVMETHOD(pci_remap_msix,	vga_pci_remap_msix),
+	DEVMETHOD(pci_release_msi,	vga_pci_release_msi),
+	DEVMETHOD(pci_msi_count,	vga_pci_msi_count),
+	DEVMETHOD(pci_msix_count,	vga_pci_msix_count),
 
 	{ 0, 0 }
 };
@@ -247,7 +420,7 @@ static device_method_t vga_pci_methods[]
 static driver_t vga_pci_driver = {
 	"vgapci",
 	vga_pci_methods,
-	1,
+	sizeof(struct vga_pci_softc),
 };
 
 static devclass_t vga_devclass;

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 14:53:58 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D1B60106566B;
	Tue,  5 May 2009 14:53:58 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BBEF88FC21;
	Tue,  5 May 2009 14:53:58 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45Erw07084373;
	Tue, 5 May 2009 14:53:58 GMT (envelope-from dchagin@svn.freebsd.org)
Received: (from dchagin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45ErwaK084362;
	Tue, 5 May 2009 14:53:58 GMT (envelope-from dchagin@svn.freebsd.org)
Message-Id: <200905051453.n45ErwaK084362@svn.freebsd.org>
From: Dmitry Chagin 
Date: Tue, 5 May 2009 14:53:58 +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: r191820 - in stable/7/sys: . amd64/linux32 compat/linux
	contrib/pf dev/ath/ath_hal dev/cxgb i386/linux
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 14:53:59 -0000

Author: dchagin
Date: Tue May  5 14:53:58 2009
New Revision: 191820
URL: http://svn.freebsd.org/changeset/base/191820

Log:
  Merge from HEAD to stable/7:
  
  r178976 (rdivacky):
  Implement robust futexes. Most of the code is modelled after
  what Linux does. This is because robust futexes are mostly
  userspace thing which we cannot alter. Two syscalls maintain
  pointer to userspace list and when process exits a routine
  walks this list waking up processes sleeping on futexes
  from that list.
  
  r183871:
  Make robust futexes work on linux32/amd64. Use PTRIN to read
  user-mode pointers. Change types used in the structures definitions to
  properly-sized architecture-specific types.
  
  r185002:
  In the robust futexes list head, futex_offset shall be signed,
  and glibc actually supplies negative offsets. Change l_ulong to l_long.
  
  Approved by:	kib (mentor)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/linux32/linux.h
  stable/7/sys/amd64/linux32/linux32_dummy.c
  stable/7/sys/amd64/linux32/syscalls.master
  stable/7/sys/compat/linux/linux_emul.c
  stable/7/sys/compat/linux/linux_emul.h
  stable/7/sys/compat/linux/linux_futex.c
  stable/7/sys/compat/linux/linux_futex.h
  stable/7/sys/compat/linux/linux_misc.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/i386/linux/linux.h
  stable/7/sys/i386/linux/linux_dummy.c
  stable/7/sys/i386/linux/syscalls.master

Modified: stable/7/sys/amd64/linux32/linux.h
==============================================================================
--- stable/7/sys/amd64/linux32/linux.h	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/amd64/linux32/linux.h	Tue May  5 14:53:58 2009	(r191820)
@@ -886,4 +886,15 @@ typedef int l_mqd_t;
 	(LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES |	\
 	LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
 
+/* robust futexes */
+struct linux_robust_list {
+	l_uintptr_t			next;
+};
+
+struct linux_robust_list_head {
+	struct linux_robust_list	list;
+	l_long				futex_offset;
+	l_uintptr_t			pending_list;
+};
+
 #endif /* !_AMD64_LINUX_H_ */

Modified: stable/7/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_dummy.c	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/amd64/linux32/linux32_dummy.c	Tue May  5 14:53:58 2009	(r191820)
@@ -111,8 +111,6 @@ DUMMY(faccessat);
 DUMMY(pselect6);
 DUMMY(ppoll);
 DUMMY(unshare);
-DUMMY(set_robust_list);
-DUMMY(get_robust_list);
 DUMMY(splice);
 DUMMY(sync_file_range);
 DUMMY(tee);

Modified: stable/7/sys/amd64/linux32/syscalls.master
==============================================================================
--- stable/7/sys/amd64/linux32/syscalls.master	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/amd64/linux32/syscalls.master	Tue May  5 14:53:58 2009	(r191820)
@@ -482,8 +482,10 @@
 308	AUE_NULL	STD	{ int linux_pselect6(void); }
 309	AUE_NULL	STD	{ int linux_ppoll(void); }
 310	AUE_NULL	STD	{ int linux_unshare(void); }
-311	AUE_NULL	STD	{ int linux_set_robust_list(void); }
-312	AUE_NULL	STD	{ int linux_get_robust_list(void); }
+311	AUE_NULL	STD	{ int linux_set_robust_list(struct linux_robust_list_head *head, \
+					l_size_t len); }
+312	AUE_NULL	STD	{ int linux_get_robust_list(l_int pid, struct linux_robust_list_head *head, \
+					l_size_t *len); }
 313	AUE_NULL	STD	{ int linux_splice(void); }
 314	AUE_NULL	STD	{ int linux_sync_file_range(void); }
 315	AUE_NULL	STD	{ int linux_tee(void); }

Modified: stable/7/sys/compat/linux/linux_emul.c
==============================================================================
--- stable/7/sys/compat/linux/linux_emul.c	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/compat/linux/linux_emul.c	Tue May  5 14:53:58 2009	(r191820)
@@ -44,9 +44,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-#include 
-
 #ifdef COMPAT_LINUX32
 #include 
 #include 
@@ -55,6 +52,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+#include 
+#include 
+
 struct sx	emul_shared_lock;
 struct mtx	emul_lock;
 
@@ -86,6 +86,7 @@ linux_proc_init(struct thread *td, pid_t
 		em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
 		em->pid = child;
 		em->pdeath_signal = 0;
+		em->robust_futexes = NULL;
 		if (flags & LINUX_CLONE_THREAD) {
 			/* handled later in the code */
 		} else {
@@ -161,6 +162,8 @@ linux_proc_exit(void *arg __unused, stru
 	if (__predict_true(p->p_sysent != &elf_linux_sysvec))
 		return;
 
+	release_futexes(p);
+
 	/* find the emuldata */
 	em = em_find(p, EMUL_DOLOCK);
 

Modified: stable/7/sys/compat/linux/linux_emul.h
==============================================================================
--- stable/7/sys/compat/linux/linux_emul.h	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/compat/linux/linux_emul.h	Tue May  5 14:53:58 2009	(r191820)
@@ -31,6 +31,8 @@
 #ifndef _LINUX_EMUL_H_
 #define	_LINUX_EMUL_H_
 
+#include 
+
 struct linux_emuldata_shared {
 	int	refs;
 	pid_t	group_pid;
@@ -52,6 +54,8 @@ struct linux_emuldata {
 
 	int	pdeath_signal;		/* parent death signal */
 
+	struct	linux_robust_list_head	*robust_futexes;
+
 	LIST_ENTRY(linux_emuldata) threads;	/* list of linux threads */
 };
 

Modified: stable/7/sys/compat/linux/linux_futex.c
==============================================================================
--- stable/7/sys/compat/linux/linux_futex.c	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/compat/linux/linux_futex.c	Tue May  5 14:53:58 2009	(r191820)
@@ -45,8 +45,11 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -57,6 +60,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include 
 #include 
 #endif
+#include 
 #include 
 
 struct futex;
@@ -533,3 +537,160 @@ futex_atomic_op(struct thread *td, int e
 		return (-ENOSYS);
 	}
 }
+
+int
+linux_set_robust_list(struct thread *td, struct linux_set_robust_list_args *args)
+{
+	struct linux_emuldata *em;
+
+#ifdef	DEBUG
+	if (ldebug(set_robust_list))
+		printf(ARGS(set_robust_list, ""));
+#endif
+	if (args->len != sizeof(struct linux_robust_list_head))
+		return (EINVAL);
+
+	em = em_find(td->td_proc, EMUL_DOLOCK);
+	em->robust_futexes = args->head;
+	EMUL_UNLOCK(&emul_lock);
+
+	return (0);	
+}
+
+int
+linux_get_robust_list(struct thread *td, struct linux_get_robust_list_args *args)
+{
+	struct linux_emuldata *em;
+	struct linux_robust_list_head *head;
+	l_size_t len = sizeof(struct linux_robust_list_head);
+	int error = 0;
+
+#ifdef	DEBUG
+	if (ldebug(get_robust_list))
+		printf(ARGS(get_robust_list, ""));
+#endif
+
+	if (!args->pid) {
+		em = em_find(td->td_proc, EMUL_DONTLOCK);
+		head = em->robust_futexes;		
+	} else {
+		struct proc *p;
+
+		p = pfind(args->pid);
+		if (p == NULL)
+			return (ESRCH);
+
+		em = em_find(p, EMUL_DONTLOCK);
+		/* XXX: ptrace? */
+		if (priv_check(td, PRIV_CRED_SETUID) || 
+		    priv_check(td, PRIV_CRED_SETEUID) ||
+		    p_candebug(td, p))
+			return (EPERM);
+		head = em->robust_futexes;
+		
+		PROC_UNLOCK(p);
+	}
+
+	error = copyout(&len, args->len, sizeof(l_size_t));
+	if (error)
+		return (EFAULT);
+
+	error = copyout(head, args->head, sizeof(struct linux_robust_list_head));
+
+	return (error);
+}
+
+static int
+handle_futex_death(void *uaddr, pid_t pid, int pi)
+{
+	int uval, nval, mval;
+	struct futex *f;
+
+retry:
+	if (copyin(uaddr, &uval, 4))
+		return (EFAULT);
+
+	if ((uval & FUTEX_TID_MASK) == pid) {
+		mval = (uval & FUTEX_WAITERS) | FUTEX_OWNER_DIED;
+		nval = casuword32(uaddr, uval, mval);
+
+		if (nval == -1)
+			return (EFAULT);
+
+		if (nval != uval)
+			goto retry;
+
+		if (!pi && (uval & FUTEX_WAITERS)) {
+			f = futex_get(uaddr, FUTEX_UNLOCKED);
+			futex_wake(f, 1, NULL, 0);
+		}
+	}
+
+	return (0);
+}
+
+static int
+fetch_robust_entry(struct linux_robust_list **entry,
+    struct linux_robust_list **head, int *pi)
+{
+	l_ulong uentry;
+
+	if (copyin((const void *)head, &uentry, sizeof(l_ulong)))
+		return (EFAULT);
+
+	*entry = (void *)(uentry & ~1UL);
+	*pi = uentry & 1;
+
+	return (0);
+}
+
+/* This walks the list of robust futexes releasing them. */
+void
+release_futexes(struct proc *p)
+{
+	struct linux_robust_list_head *head = NULL;
+	struct linux_robust_list *entry, *next_entry, *pending;
+	unsigned int limit = 2048, pi, next_pi, pip;
+	struct linux_emuldata *em;
+	l_long futex_offset;
+	int rc;
+
+	em = em_find(p, EMUL_DONTLOCK);
+	head = em->robust_futexes;
+
+	if (head == NULL)
+		return;
+
+	if (fetch_robust_entry(&entry, PTRIN(&head->list.next), &pi))
+		return;
+
+	if (copyin(&head->futex_offset, &futex_offset, sizeof(futex_offset)))
+		return;
+
+	if (fetch_robust_entry(&pending, PTRIN(&head->pending_list), &pip))
+		return;
+
+	while (entry != &head->list) {
+		rc = fetch_robust_entry(&next_entry, PTRIN(&entry->next), &next_pi);
+
+		if (entry != pending)
+			if (handle_futex_death((char *)entry + futex_offset,
+			    p->p_pid, pi))
+				return;
+
+		if (rc)
+			return;
+
+		entry = next_entry;
+		pi = next_pi;
+
+		if (!--limit)
+			break;
+
+		sched_relinquish(curthread);
+	}
+
+	if (pending)
+		handle_futex_death((char *) pending + futex_offset,
+		    p->p_pid, pip);
+}

Modified: stable/7/sys/compat/linux/linux_futex.h
==============================================================================
--- stable/7/sys/compat/linux/linux_futex.h	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/compat/linux/linux_futex.h	Tue May  5 14:53:58 2009	(r191820)
@@ -63,4 +63,10 @@
 #define FUTEX_OP_CMP_GT         4	/* if (oldval > CMPARG) wake */
 #define FUTEX_OP_CMP_GE         5	/* if (oldval >= CMPARG) wake */
 
+#define	FUTEX_WAITERS		0x80000000
+#define	FUTEX_OWNER_DIED	0x40000000
+#define	FUTEX_TID_MASK		0x3fffffff
+
+void	release_futexes(struct proc *);
+
 #endif	/* !_LINUX_FUTEX_H */

Modified: stable/7/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/7/sys/compat/linux/linux_misc.c	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/compat/linux/linux_misc.c	Tue May  5 14:53:58 2009	(r191820)
@@ -75,10 +75,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-#include 
-#include 
-
 #ifdef COMPAT_LINUX32
 #include 
 #include 
@@ -90,6 +86,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #define BSD_TO_LINUX_SIGNAL(sig)	\
 	(((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)

Modified: stable/7/sys/i386/linux/linux.h
==============================================================================
--- stable/7/sys/i386/linux/linux.h	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/i386/linux/linux.h	Tue May  5 14:53:58 2009	(r191820)
@@ -851,4 +851,15 @@ typedef int l_mqd_t;
 	(LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES |	\
 	LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
 
+/* robust futexes */
+struct linux_robust_list {
+	struct linux_robust_list	*next;
+};
+
+struct linux_robust_list_head {
+	struct linux_robust_list	list;
+	l_long				futex_offset;
+	struct linux_robust_list	*pending_list;
+};
+
 #endif /* !_I386_LINUX_H_ */

Modified: stable/7/sys/i386/linux/linux_dummy.c
==============================================================================
--- stable/7/sys/i386/linux/linux_dummy.c	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/i386/linux/linux_dummy.c	Tue May  5 14:53:58 2009	(r191820)
@@ -102,8 +102,6 @@ DUMMY(faccessat);
 DUMMY(pselect6);
 DUMMY(ppoll);
 DUMMY(unshare);
-DUMMY(set_robust_list);
-DUMMY(get_robust_list);
 DUMMY(splice);
 DUMMY(sync_file_range);
 DUMMY(tee);

Modified: stable/7/sys/i386/linux/syscalls.master
==============================================================================
--- stable/7/sys/i386/linux/syscalls.master	Tue May  5 14:46:18 2009	(r191819)
+++ stable/7/sys/i386/linux/syscalls.master	Tue May  5 14:53:58 2009	(r191820)
@@ -492,8 +492,10 @@
 308	AUE_NULL	STD	{ int linux_pselect6(void); }
 309	AUE_NULL	STD	{ int linux_ppoll(void); }
 310	AUE_NULL	STD	{ int linux_unshare(void); }
-311	AUE_NULL	STD	{ int linux_set_robust_list(void); }
-312	AUE_NULL	STD	{ int linux_get_robust_list(void); }
+311	AUE_NULL	STD	{ int linux_set_robust_list(struct linux_robust_list_head *head, \
+					l_size_t len); }
+312	AUE_NULL	STD	{ int linux_get_robust_list(l_int pid, struct linux_robust_list_head **head, \
+					l_size_t *len); }
 313	AUE_NULL	STD	{ int linux_splice(void); }
 314	AUE_NULL	STD	{ int linux_sync_file_range(void); }
 315	AUE_NULL	STD	{ int linux_tee(void); }

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 14:55:23 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E07371065670;
	Tue,  5 May 2009 14:55:23 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CBCDF8FC13;
	Tue,  5 May 2009 14:55:23 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45EtNTs084465;
	Tue, 5 May 2009 14:55:23 GMT (envelope-from dchagin@svn.freebsd.org)
Received: (from dchagin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45EtN7c084459;
	Tue, 5 May 2009 14:55:23 GMT (envelope-from dchagin@svn.freebsd.org)
Message-Id: <200905051455.n45EtN7c084459@svn.freebsd.org>
From: Dmitry Chagin 
Date: Tue, 5 May 2009 14:55: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: r191821 - in stable/7/sys: amd64/linux32 i386/linux
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 14:55:24 -0000

Author: dchagin
Date: Tue May  5 14:55:23 2009
New Revision: 191821
URL: http://svn.freebsd.org/changeset/base/191821

Log:
  Regenerate syscall table after 191820.
  
  Approved by:	kib (mentor)

Modified:
  stable/7/sys/amd64/linux32/linux32_proto.h
  stable/7/sys/amd64/linux32/linux32_syscall.h
  stable/7/sys/amd64/linux32/linux32_sysent.c
  stable/7/sys/i386/linux/linux_proto.h
  stable/7/sys/i386/linux/linux_syscall.h
  stable/7/sys/i386/linux/linux_sysent.c

Modified: stable/7/sys/amd64/linux32/linux32_proto.h
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_proto.h	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/amd64/linux32/linux32_proto.h	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -937,10 +937,13 @@ struct linux_unshare_args {
 	register_t dummy;
 };
 struct linux_set_robust_list_args {
-	register_t dummy;
+	char head_l_[PADL_(struct linux_robust_list_head *)]; struct linux_robust_list_head * head; char head_r_[PADR_(struct linux_robust_list_head *)];
+	char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
 };
 struct linux_get_robust_list_args {
-	register_t dummy;
+	char pid_l_[PADL_(l_int)]; l_int pid; char pid_r_[PADR_(l_int)];
+	char head_l_[PADL_(struct linux_robust_list_head *)]; struct linux_robust_list_head * head; char head_r_[PADR_(struct linux_robust_list_head *)];
+	char len_l_[PADL_(l_size_t *)]; l_size_t * len; char len_r_[PADR_(l_size_t *)];
 };
 struct linux_splice_args {
 	register_t dummy;

Modified: stable/7/sys/amd64/linux32/linux32_syscall.h
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_syscall.h	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/amd64/linux32/linux32_syscall.h	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #define	LINUX_SYS_exit	1

Modified: stable/7/sys/amd64/linux32/linux32_sysent.c
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_sysent.c	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/amd64/linux32/linux32_sysent.c	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/amd64/linux32/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #include "opt_compat.h"
@@ -330,8 +330,8 @@ struct sysent linux_sysent[] = {
 	{ 0, (sy_call_t *)linux_pselect6, AUE_NULL, NULL, 0, 0 },	/* 308 = linux_pselect6 */
 	{ 0, (sy_call_t *)linux_ppoll, AUE_NULL, NULL, 0, 0 },	/* 309 = linux_ppoll */
 	{ 0, (sy_call_t *)linux_unshare, AUE_NULL, NULL, 0, 0 },	/* 310 = linux_unshare */
-	{ 0, (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 },	/* 311 = linux_set_robust_list */
-	{ 0, (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 },	/* 312 = linux_get_robust_list */
+	{ AS(linux_set_robust_list_args), (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 },	/* 311 = linux_set_robust_list */
+	{ AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 },	/* 312 = linux_get_robust_list */
 	{ 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0 },	/* 313 = linux_splice */
 	{ 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0 },	/* 314 = linux_sync_file_range */
 	{ 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0 },		/* 315 = linux_tee */

Modified: stable/7/sys/i386/linux/linux_proto.h
==============================================================================
--- stable/7/sys/i386/linux/linux_proto.h	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/i386/linux/linux_proto.h	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -956,10 +956,13 @@ struct linux_unshare_args {
 	register_t dummy;
 };
 struct linux_set_robust_list_args {
-	register_t dummy;
+	char head_l_[PADL_(struct linux_robust_list_head *)]; struct linux_robust_list_head * head; char head_r_[PADR_(struct linux_robust_list_head *)];
+	char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
 };
 struct linux_get_robust_list_args {
-	register_t dummy;
+	char pid_l_[PADL_(l_int)]; l_int pid; char pid_r_[PADR_(l_int)];
+	char head_l_[PADL_(struct linux_robust_list_head **)]; struct linux_robust_list_head ** head; char head_r_[PADR_(struct linux_robust_list_head **)];
+	char len_l_[PADL_(l_size_t *)]; l_size_t * len; char len_r_[PADR_(l_size_t *)];
 };
 struct linux_splice_args {
 	register_t dummy;

Modified: stable/7/sys/i386/linux/linux_syscall.h
==============================================================================
--- stable/7/sys/i386/linux/linux_syscall.h	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/i386/linux/linux_syscall.h	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #define	LINUX_SYS_exit	1

Modified: stable/7/sys/i386/linux/linux_sysent.c
==============================================================================
--- stable/7/sys/i386/linux/linux_sysent.c	Tue May  5 14:53:58 2009	(r191820)
+++ stable/7/sys/i386/linux/linux_sysent.c	Tue May  5 14:55:23 2009	(r191821)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191804 2009-05-05 03:49:30Z dchagin 
+ * created from FreeBSD: stable/7/sys/i386/linux/syscalls.master 191820 2009-05-05 14:53:58Z dchagin 
  */
 
 #include 
@@ -329,8 +329,8 @@ struct sysent linux_sysent[] = {
 	{ 0, (sy_call_t *)linux_pselect6, AUE_NULL, NULL, 0, 0 },	/* 308 = linux_pselect6 */
 	{ 0, (sy_call_t *)linux_ppoll, AUE_NULL, NULL, 0, 0 },	/* 309 = linux_ppoll */
 	{ 0, (sy_call_t *)linux_unshare, AUE_NULL, NULL, 0, 0 },	/* 310 = linux_unshare */
-	{ 0, (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 },	/* 311 = linux_set_robust_list */
-	{ 0, (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 },	/* 312 = linux_get_robust_list */
+	{ AS(linux_set_robust_list_args), (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0 },	/* 311 = linux_set_robust_list */
+	{ AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0 },	/* 312 = linux_get_robust_list */
 	{ 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0 },	/* 313 = linux_splice */
 	{ 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0 },	/* 314 = linux_sync_file_range */
 	{ 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0 },		/* 315 = linux_tee */

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 15:19:46 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 602251065673;
	Tue,  5 May 2009 15:19:46 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 42C1B8FC29;
	Tue,  5 May 2009 15:19:46 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45FJkTP085116;
	Tue, 5 May 2009 15:19:46 GMT (envelope-from dchagin@svn.freebsd.org)
Received: (from dchagin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45FJkZ1085113;
	Tue, 5 May 2009 15:19:46 GMT (envelope-from dchagin@svn.freebsd.org)
Message-Id: <200905051519.n45FJkZ1085113@svn.freebsd.org>
From: Dmitry Chagin 
Date: Tue, 5 May 2009 15:19:46 +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: r191823 - in stable/7/sys: . compat/linux contrib/pf
	dev/ath/ath_hal dev/cxgb
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 15:19:47 -0000

Author: dchagin
Date: Tue May  5 15:19:45 2009
New Revision: 191823
URL: http://svn.freebsd.org/changeset/base/191823

Log:
  Merge from HEAD to stable/7:
  
  r189861:
  Include linux_futex.h before linux_emul.h
  
  r189862:
  Ignore FUTEX_FD op, as it is done by linux.
  
  r189867:
  Sort include files in the alphabetical order.
  
  Approved by:	kib (mentor)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/compat/linux/linux_emul.h
  stable/7/sys/compat/linux/linux_futex.c
  stable/7/sys/compat/linux/linux_futex.h
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)

Modified: stable/7/sys/compat/linux/linux_emul.h
==============================================================================
--- stable/7/sys/compat/linux/linux_emul.h	Tue May  5 15:03:19 2009	(r191822)
+++ stable/7/sys/compat/linux/linux_emul.h	Tue May  5 15:19:45 2009	(r191823)
@@ -31,8 +31,6 @@
 #ifndef _LINUX_EMUL_H_
 #define	_LINUX_EMUL_H_
 
-#include 
-
 struct linux_emuldata_shared {
 	int	refs;
 	pid_t	group_pid;

Modified: stable/7/sys/compat/linux/linux_futex.c
==============================================================================
--- stable/7/sys/compat/linux/linux_futex.c	Tue May  5 15:03:19 2009	(r191822)
+++ stable/7/sys/compat/linux/linux_futex.c	Tue May  5 15:19:45 2009	(r191823)
@@ -40,18 +40,17 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include "opt_compat.h"
 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
 
 #ifdef COMPAT_LINUX32
 #include 
@@ -60,8 +59,8 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include 
 #include 
 #endif
-#include 
 #include 
+#include 
 
 struct futex;
 
@@ -276,13 +275,6 @@ linux_sys_futex(struct thread *td, struc
 		FUTEX_SYSTEM_UNLOCK;
 		break;
 
-	case LINUX_FUTEX_FD:
-#ifdef DEBUG
-		printf("linux_sys_futex: unimplemented op %d\n",
-		    args->op);
-#endif
-		return (ENOSYS);
-
 	case LINUX_FUTEX_WAKE_OP:
 		FUTEX_SYSTEM_LOCK;
 #ifdef DEBUG

Modified: stable/7/sys/compat/linux/linux_futex.h
==============================================================================
--- stable/7/sys/compat/linux/linux_futex.h	Tue May  5 15:03:19 2009	(r191822)
+++ stable/7/sys/compat/linux/linux_futex.h	Tue May  5 15:19:45 2009	(r191823)
@@ -38,7 +38,7 @@
 
 #define LINUX_FUTEX_WAIT	0
 #define LINUX_FUTEX_WAKE	1
-#define LINUX_FUTEX_FD		2
+#define LINUX_FUTEX_FD		2	/* unused */
 #define LINUX_FUTEX_REQUEUE	3
 #define LINUX_FUTEX_CMP_REQUEUE	4
 #define LINUX_FUTEX_WAKE_OP	5

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 16:37:34 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 20058106566B;
	Tue,  5 May 2009 16:37:34 +0000 (UTC)
	(envelope-from remko@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D3688FC1A;
	Tue,  5 May 2009 16:37:34 +0000 (UTC)
	(envelope-from remko@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45GbXo8087204;
	Tue, 5 May 2009 16:37:33 GMT (envelope-from remko@svn.freebsd.org)
Received: (from remko@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45GbXCY087203;
	Tue, 5 May 2009 16:37:33 GMT (envelope-from remko@svn.freebsd.org)
Message-Id: <200905051637.n45GbXCY087203@svn.freebsd.org>
From: Remko Lodder 
Date: Tue, 5 May 2009 16:37: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: r191830 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb dev/usb
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 16:37:34 -0000

Author: remko
Date: Tue May  5 16:37:33 2009
New Revision: 191830
URL: http://svn.freebsd.org/changeset/base/191830

Log:
  MFC r182896
  
    Add support for the CyberPower CP1500AVRLCD.
  
    PR: 126845
    Submitted by: gavin
    Approved by: imp (mentor, implicit)
    MFC after: 1 week
  
  Approved by:	imp (mentor, implicit)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/usb/usb_quirks.c

Modified: stable/7/sys/dev/usb/usb_quirks.c
==============================================================================
--- stable/7/sys/dev/usb/usb_quirks.c	Tue May  5 16:29:08 2009	(r191829)
+++ stable/7/sys/dev/usb/usb_quirks.c	Tue May  5 16:37:33 2009	(r191830)
@@ -98,6 +98,8 @@ static const struct usbd_quirk_entry {
 	ANY, { UQ_HID_IGNORE }},
  { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR,
 	ANY, { UQ_HID_IGNORE }},
+ { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_1500CAVRLCD,
+	ANY, { UQ_HID_IGNORE }},
  { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
 	ANY, { UQ_HID_IGNORE }},
  { USB_VENDOR_ITUNERNET, USB_PRODUCT_ITUNERNET_USBLCD2X20,

From owner-svn-src-stable-7@FreeBSD.ORG  Tue May  5 18:02:07 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D5B6C1065700;
	Tue,  5 May 2009 18:02:07 +0000 (UTC) (envelope-from avg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C2C558FC13;
	Tue,  5 May 2009 18:02:07 +0000 (UTC) (envelope-from avg@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n45I27RL089305;
	Tue, 5 May 2009 18:02:07 GMT (envelope-from avg@svn.freebsd.org)
Received: (from avg@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n45I27T1089303;
	Tue, 5 May 2009 18:02:07 GMT (envelope-from avg@svn.freebsd.org)
Message-Id: <200905051802.n45I27T1089303@svn.freebsd.org>
From: Andriy Gapon 
Date: Tue, 5 May 2009 18:02:07 +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: r191833 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb kern
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Tue, 05 May 2009 18:02:09 -0000

Author: avg
Date: Tue May  5 18:02:07 2009
New Revision: 191833
URL: http://svn.freebsd.org/changeset/base/191833

Log:
  MFC r174848 by julian: give thread0 the tid 100000
  
  ... and bumpt the others to start at 100001.
  This is convenient for ACPI code that needs a thread id that is
  never zero.
  
  Reviewed by:	jkim
  Approved by:	jhb (mentor)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/kern/init_main.c
  stable/7/sys/kern/kern_thread.c

Modified: stable/7/sys/kern/init_main.c
==============================================================================
--- stable/7/sys/kern/init_main.c	Tue May  5 17:22:48 2009	(r191832)
+++ stable/7/sys/kern/init_main.c	Tue May  5 18:02:07 2009	(r191833)
@@ -425,6 +425,7 @@ proc0_init(void *dummy __unused)
 	knlist_init(&p->p_klist, &p->p_mtx, NULL, NULL, NULL);
 	STAILQ_INIT(&p->p_ktr);
 	p->p_nice = NZERO;
+	td->td_tid = PID_MAX + 1;
 	td->td_state = TDS_RUNNING;
 	td->td_pri_class = PRI_TIMESHARE;
 	td->td_user_pri = PUSER;

Modified: stable/7/sys/kern/kern_thread.c
==============================================================================
--- stable/7/sys/kern/kern_thread.c	Tue May  5 17:22:48 2009	(r191832)
+++ stable/7/sys/kern/kern_thread.c	Tue May  5 18:02:07 2009	(r191833)
@@ -252,7 +252,8 @@ threadinit(void)
 {
 
 	mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF);
-	tid_unrhdr = new_unrhdr(PID_MAX + 1, INT_MAX, &tid_lock);
+	/* leave one number for thread0 */
+	tid_unrhdr = new_unrhdr(PID_MAX + 2, INT_MAX, &tid_lock);
 
 	thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
 	    thread_ctor, thread_dtor, thread_init, thread_fini,

From owner-svn-src-stable-7@FreeBSD.ORG  Wed May  6 22:26:04 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 60BAE10656CF;
	Wed,  6 May 2009 22:26:04 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4DBA78FC1C;
	Wed,  6 May 2009 22:26:04 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n46MQ4qa031715;
	Wed, 6 May 2009 22:26:04 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n46MQ4OI031714;
	Wed, 6 May 2009 22:26:04 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <200905062226.n46MQ4OI031714@svn.freebsd.org>
From: Xin LI 
Date: Wed, 6 May 2009 22:26:04 +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: r191860 - stable/7/usr.bin/truss
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 06 May 2009 22:26:05 -0000

Author: delphij
Date: Wed May  6 22:26:04 2009
New Revision: 191860
URL: http://svn.freebsd.org/changeset/base/191860

Log:
  MFC r191004:
  
  Correct a bug where pr_data should have been assigned.

Modified:
  stable/7/usr.bin/truss/   (props changed)
  stable/7/usr.bin/truss/setup.c

Modified: stable/7/usr.bin/truss/setup.c
==============================================================================
--- stable/7/usr.bin/truss/setup.c	Wed May  6 20:48:45 2009	(r191859)
+++ stable/7/usr.bin/truss/setup.c	Wed May  6 22:26:04 2009	(r191860)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copryight 1997 Sean Eric Fagan
  *
  * Redistribution and use in source and binary forms, with or without
@@ -214,8 +214,8 @@ waitevent(struct trussinfo *info)
 		}
 	}
 	if (WIFSIGNALED(waitval)) {
-	        info->pr_why = S_EXIT;
-		info->pr_why = 0;
-                return;
+		info->pr_why = S_EXIT;
+		info->pr_data = 0;
+		return;
 	}
 }

From owner-svn-src-stable-7@FreeBSD.ORG  Wed May  6 22:26:49 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E5BC51065675;
	Wed,  6 May 2009 22:26:49 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D33488FC17;
	Wed,  6 May 2009 22:26:49 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n46MQn1P031774;
	Wed, 6 May 2009 22:26:49 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n46MQnGK031773;
	Wed, 6 May 2009 22:26:49 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <200905062226.n46MQnGK031773@svn.freebsd.org>
From: Xin LI 
Date: Wed, 6 May 2009 22:26:49 +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: r191861 - stable/7/usr.bin/truss
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 06 May 2009 22:26:50 -0000

Author: delphij
Date: Wed May  6 22:26:49 2009
New Revision: 191861
URL: http://svn.freebsd.org/changeset/base/191861

Log:
  MFC r191005:
  
  Don't exit until all truss children were exit.

Modified:
  stable/7/usr.bin/truss/   (props changed)
  stable/7/usr.bin/truss/main.c

Modified: stable/7/usr.bin/truss/main.c
==============================================================================
--- stable/7/usr.bin/truss/main.c	Wed May  6 22:26:04 2009	(r191860)
+++ stable/7/usr.bin/truss/main.c	Wed May  6 22:26:49 2009	(r191861)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copryight 1997 Sean Eric Fagan
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -159,6 +160,8 @@ main(int ac, char **av)
 {
 	int c;
 	int i;
+	pid_t childpid;
+	int status;
 	char **command;
 	struct ex_types *funcs;
 	int initial_open;
@@ -283,8 +286,6 @@ START_TRACE:
 
 			if (trussinfo->curthread->in_fork &&
 			    (trussinfo->flags & FOLLOWFORKS)) {
-				int childpid;
-
 				trussinfo->curthread->in_fork = 0;
 				childpid =
 				    funcs->exit_syscall(trussinfo,
@@ -355,6 +356,11 @@ START_TRACE:
 		}
 	} while (trussinfo->pr_why != S_EXIT);
 	fflush(trussinfo->outfile);
-	
+
+	if (trussinfo->flags & FOLLOWFORKS)
+		do {
+			childpid = wait(&status);
+		} while (childpid != -1);
+
 	return (0);
 }

From owner-svn-src-stable-7@FreeBSD.ORG  Thu May  7 01:14:59 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8A229106566C;
	Thu,  7 May 2009 01:14:59 +0000 (UTC)
	(envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 770B48FC18;
	Thu,  7 May 2009 01:14:59 +0000 (UTC)
	(envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n471ExG6035632;
	Thu, 7 May 2009 01:14:59 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n471Exp3035631;
	Thu, 7 May 2009 01:14:59 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <200905070114.n471Exp3035631@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Thu, 7 May 2009 01:14:59 +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: r191867 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb dev/fxp
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 07 May 2009 01:15:00 -0000

Author: yongari
Date: Thu May  7 01:14:59 2009
New Revision: 191867
URL: http://svn.freebsd.org/changeset/base/191867

Log:
  MFC r190982:
    Don't blindly set IP packet length from interface MTU in TSO case.
    Remote host can advertise smaller MSS than that of sender so upper
    stack might have adjusted the MSS which in turn generates IP
    packets that are less size than that of interface MTU.
  
    Reported by:	Bjoern Koenig ( bkoenig <> alpha-tierchen dot de )

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/fxp/if_fxp.c

Modified: stable/7/sys/dev/fxp/if_fxp.c
==============================================================================
--- stable/7/sys/dev/fxp/if_fxp.c	Thu May  7 00:35:32 2009	(r191866)
+++ stable/7/sys/dev/fxp/if_fxp.c	Thu May  7 01:14:59 2009	(r191867)
@@ -1486,7 +1486,8 @@ fxp_encap(struct fxp_softc *sc, struct m
 		 * checksum in the first frame driver should compute it.
 		 */
 		ip->ip_sum = 0;
-		ip->ip_len = htons(ifp->if_mtu);
+		ip->ip_len = htons(m->m_pkthdr.tso_segsz + (ip->ip_hl << 2) +
+		    (tcp->th_off << 2));
 		tcp->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
 		    htons(IPPROTO_TCP + (tcp->th_off << 2) +
 		    m->m_pkthdr.tso_segsz));

From owner-svn-src-stable-7@FreeBSD.ORG  Thu May  7 10:37:24 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2A398106566C;
	Thu,  7 May 2009 10:37:24 +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 52AA48FC24;
	Thu,  7 May 2009 10:37:23 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n47AbM8h053189;
	Thu, 7 May 2009 10:37:22 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n47AbM9M053188;
	Thu, 7 May 2009 10:37:22 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200905071037.n47AbM9M053188@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 7 May 2009 10:37: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: r191878 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb vm
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 07 May 2009 10:37:24 -0000

Author: kib
Date: Thu May  7 10:37:22 2009
New Revision: 191878
URL: http://svn.freebsd.org/changeset/base/191878

Log:
  MFC r191439:
  Do not call vm_page_lookup() from the ddb routine, namely from "show
  vmopag" implementation. Iterate over memq to calculate the runs. Make
  the code slightly more style-compliant.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/vm/vm_object.c

Modified: stable/7/sys/vm/vm_object.c
==============================================================================
--- stable/7/sys/vm/vm_object.c	Thu May  7 10:01:05 2009	(r191877)
+++ stable/7/sys/vm/vm_object.c	Thu May  7 10:37:22 2009	(r191878)
@@ -2197,16 +2197,13 @@ vm_object_print(
 DB_SHOW_COMMAND(vmopag, vm_object_print_pages)
 {
 	vm_object_t object;
-	int nl = 0;
-	int c;
+	vm_pindex_t fidx;
+	vm_paddr_t pa;
+	vm_page_t m, prev_m;
+	int rcount, nl, c;
 
+	nl = 0;
 	TAILQ_FOREACH(object, &vm_object_list, object_list) {
-		vm_pindex_t idx, fidx;
-		vm_pindex_t osize;
-		vm_paddr_t pa = -1;
-		int rcount;
-		vm_page_t m;
-
 		db_printf("new object: %p\n", (void *)object);
 		if (nl > 18) {
 			c = cngetc();
@@ -2217,12 +2214,12 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_
 		nl++;
 		rcount = 0;
 		fidx = 0;
-		osize = object->size;
-		if (osize > 128)
-			osize = 128;
-		for (idx = 0; idx < osize; idx++) {
-			m = vm_page_lookup(object, idx);
-			if (m == NULL) {
+		pa = -1;
+		TAILQ_FOREACH(m, &object->memq, listq) {
+			if (m->pindex > 128)
+				break;
+			if ((prev_m = TAILQ_PREV(m, pglist, listq)) != NULL &&
+			    prev_m->pindex + 1 != m->pindex) {
 				if (rcount) {
 					db_printf(" index(%ld)run(%d)pa(0x%lx)\n",
 						(long)fidx, rcount, (long)pa);
@@ -2235,10 +2232,7 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_
 					nl++;
 					rcount = 0;
 				}
-				continue;
-			}
-
-				
+			}				
 			if (rcount &&
 				(VM_PAGE_TO_PHYS(m) == pa + rcount * PAGE_SIZE)) {
 				++rcount;
@@ -2255,7 +2249,7 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_
 				}
 				nl++;
 			}
-			fidx = idx;
+			fidx = m->pindex;
 			pa = VM_PAGE_TO_PHYS(m);
 			rcount = 1;
 		}

From owner-svn-src-stable-7@FreeBSD.ORG  Fri May  8 04:32:47 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2FFC5106566B
	for ;
	Fri,  8 May 2009 04:32:47 +0000 (UTC)
	(envelope-from lauren@rhodamine.com.au)
Received: from rhodamine.com.au (dsl-210-15-212-138-static.VIC.netspace.net.au
	[210.15.212.138])
	by mx1.freebsd.org (Postfix) with ESMTP id C81CA8FC17
	for ;
	Fri,  8 May 2009 04:32:46 +0000 (UTC)
	(envelope-from lauren@rhodamine.com.au)
Received: by rhodamine.com.au (Postfix, from userid 1036)
	id 60C1E2212964; Fri,  8 May 2009 13:53:58 +1000 (EST)
To: svn-src-stable-7@freebsd.org
From: received@postcard.org 
Message-Id: <20090508035358.60C1E2212964@rhodamine.com.au>
Date: Fri,  8 May 2009 13:53:58 +1000 (EST)
MIME-Version: 1.0
Content-Type: text/plain
X-Content-Filtered-By: Mailman/MimeDel 2.1.5
Subject: You have just received a virtual postcard from a friend !
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Fri, 08 May 2009 04:32:49 -0000



   You have just received a virtual postcard from a friend !

   .

   You can pick up your postcard at the following web address:

   .

   [1]http:.exe

   .

   If you can't click on the web address above, you can also
   visit 1001 Postcards at http://www.postcards.org/postcards/
   and enter your pickup code, which is: d21-sea-sunset

   .

   (Your postcard will be available for 60 days.)

   .

   Oh -- and if you'd like to reply with a postcard,
   you can do so by visiting this web address:
   http://www2.postcards.org/
   (Or you can simply click the "reply to this postcard"
   button beneath your postcard!)

   .

   We hope you enjoy your postcard, and if you do,
   please take a moment to send a few yourself!

   .

   Regards,
   1001 Postcards
   http://www.postcards.org/postcards/

References

   1. http://85.17.150.185/~paco/postcard.gif.exe

From owner-svn-src-stable-7@FreeBSD.ORG  Fri May  8 14:01:40 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A21861065674;
	Fri,  8 May 2009 14:01:40 +0000 (UTC)
	(envelope-from philip@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 749B98FC21;
	Fri,  8 May 2009 14:01:40 +0000 (UTC)
	(envelope-from philip@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n48E1eWJ093043;
	Fri, 8 May 2009 14:01:40 GMT (envelope-from philip@svn.freebsd.org)
Received: (from philip@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n48E1eWA093041;
	Fri, 8 May 2009 14:01:40 GMT (envelope-from philip@svn.freebsd.org)
Message-Id: <200905081401.n48E1eWA093041@svn.freebsd.org>
From: Philip Paeps 
Date: Fri, 8 May 2009 14:01: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: r191913 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb dev/ubsec
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Fri, 08 May 2009 14:01:41 -0000

Author: philip
Date: Fri May  8 14:01:40 2009
New Revision: 191913
URL: http://svn.freebsd.org/changeset/base/191913

Log:
  MFC r191894: Add PCI IDs for the Broadcom 5825 incarnation.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/ubsec/ubsec.c
  stable/7/sys/dev/ubsec/ubsecreg.h

Modified: stable/7/sys/dev/ubsec/ubsec.c
==============================================================================
--- stable/7/sys/dev/ubsec/ubsec.c	Fri May  8 13:44:33 2009	(r191912)
+++ stable/7/sys/dev/ubsec/ubsec.c	Fri May  8 14:01:40 2009	(r191913)
@@ -220,7 +220,8 @@ ubsec_probe(device_t dev)
 	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5820 ||
 	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5821 ||
 	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5822 ||
-	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5823
+	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5823 ||
+	     pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5825
 	     ))
 		return (BUS_PROBE_DEFAULT);
 	return (ENXIO);
@@ -240,6 +241,7 @@ ubsec_partname(struct ubsec_softc *sc)
 		case PCI_PRODUCT_BROADCOM_5821:	return "Broadcom 5821";
 		case PCI_PRODUCT_BROADCOM_5822:	return "Broadcom 5822";
 		case PCI_PRODUCT_BROADCOM_5823:	return "Broadcom 5823";
+		case PCI_PRODUCT_BROADCOM_5825:	return "Broadcom 5825";
 		}
 		return "Broadcom unknown-part";
 	case PCI_VENDOR_BLUESTEEL:
@@ -301,7 +303,8 @@ ubsec_attach(device_t dev)
 	if ((pci_get_vendor(dev) == PCI_VENDOR_BROADCOM &&
 	     (pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5821 ||
 	      pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5822 ||
-	      pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5823)) ||
+	      pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5823 ||
+	      pci_get_device(dev) == PCI_PRODUCT_BROADCOM_5825)) ||
 	    (pci_get_vendor(dev) == PCI_VENDOR_SUN &&
 	     (pci_get_device(dev) == PCI_PRODUCT_SUN_SCA1K ||
 	      pci_get_device(dev) == PCI_PRODUCT_SUN_5821))) {

Modified: stable/7/sys/dev/ubsec/ubsecreg.h
==============================================================================
--- stable/7/sys/dev/ubsec/ubsecreg.h	Fri May  8 13:44:33 2009	(r191912)
+++ stable/7/sys/dev/ubsec/ubsecreg.h	Fri May  8 14:01:40 2009	(r191913)
@@ -62,6 +62,7 @@
 #define	PCI_PRODUCT_BROADCOM_5821	0x5821		/* 5821 */
 #define	PCI_PRODUCT_BROADCOM_5822	0x5822		/* 5822 */
 #define	PCI_PRODUCT_BROADCOM_5823	0x5823		/* 5823 */
+#define	PCI_PRODUCT_BROADCOM_5825	0x5825		/* 5825 */
 
 /* Sun Microsystems */
 #define PCI_PRODUCT_SUN_5821		0x5454		/* Crypto 5821 */

From owner-svn-src-stable-7@FreeBSD.ORG  Sat May  9 00:35:39 2009
Return-Path: 
Delivered-To: svn-src-stable-7@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4BDC5106564A;
	Sat,  9 May 2009 00:35:39 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3788F8FC20;
	Sat,  9 May 2009 00:35:39 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n490Zc6C006956;
	Sat, 9 May 2009 00:35:38 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n490Zcal006955;
	Sat, 9 May 2009 00:35:38 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <200905090035.n490Zcal006955@svn.freebsd.org>
From: Xin LI 
Date: Sat, 9 May 2009 00:35: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: r191929 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
	dev/cxgb netinet
X-BeenThere: svn-src-stable-7@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 7-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Sat, 09 May 2009 00:35:41 -0000

Author: delphij
Date: Sat May  9 00:35:38 2009
New Revision: 191929
URL: http://svn.freebsd.org/changeset/base/191929

Log:
  MFC r176093 (glebius):
  
  If the vhid already present, return EEXIST instead of
  non-informative EINVAL.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/netinet/ip_carp.c

Modified: stable/7/sys/netinet/ip_carp.c
==============================================================================
--- stable/7/sys/netinet/ip_carp.c	Fri May  8 23:47:49 2009	(r191928)
+++ stable/7/sys/netinet/ip_carp.c	Sat May  9 00:35:38 2009	(r191929)
@@ -1534,7 +1534,7 @@ carp_set_addr(struct carp_softc *sc, str
 		TAILQ_FOREACH(vr, &cif->vhif_vrs, sc_list)
 			if (vr != sc && vr->sc_vhid == sc->sc_vhid) {
 				CARP_UNLOCK(cif);
-				error = EINVAL;
+				error = EEXIST;
 				goto cleanup;
 			}
 	}