From owner-svn-src-stable-7@FreeBSD.ORG Sun Sep 12 18:50:57 2010 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 EC888106564A; Sun, 12 Sep 2010 18:50:57 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB8278FC18; Sun, 12 Sep 2010 18:50:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8CIovjs099280; Sun, 12 Sep 2010 18:50:57 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8CIovmf099278; Sun, 12 Sep 2010 18:50:57 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201009121850.o8CIovmf099278@svn.freebsd.org> From: Glen Barber Date: Sun, 12 Sep 2010 18:50: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: r212504 - stable/7/share/man/man5 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, 12 Sep 2010 18:50:58 -0000 Author: gjb (doc committer) Date: Sun Sep 12 18:50:57 2010 New Revision: 212504 URL: http://svn.freebsd.org/changeset/base/212504 Log: MFC 212241. Note that jail_list should contain alphanumeric characters only. PR: 150098 Approved by: keramida (mentor) Modified: stable/7/share/man/man5/rc.conf.5 Modified: stable/7/share/man/man5/rc.conf.5 ============================================================================== --- stable/7/share/man/man5/rc.conf.5 Sun Sep 12 18:37:34 2010 (r212503) +++ stable/7/share/man/man5/rc.conf.5 Sun Sep 12 18:50:57 2010 (r212504) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 11, 2009 +.Dd September 4, 2010 .Dt RC.CONF 5 .Os .Sh NAME @@ -3369,7 +3369,8 @@ A space separated list of names for jail This is purely a configuration aid to help identify and configure multiple jails. The names specified in this list will be used to -identify settings common to an instance of a jail. +identify settings common to an instance of a jail, +and should contain alphanumeric characters only. Assuming that the jail in question was named .Li vjail , you would have the following dependent variables: From owner-svn-src-stable-7@FreeBSD.ORG Mon Sep 13 17:23:18 2010 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 EFFBC106566B; Mon, 13 Sep 2010 17:23:18 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D33C98FC1E; Mon, 13 Sep 2010 17:23:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8DHNIGE018553; Mon, 13 Sep 2010 17:23:18 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8DHNIPI018550; Mon, 13 Sep 2010 17:23:18 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201009131723.o8DHNIPI018550@svn.freebsd.org> From: Matthew D Fleming Date: Mon, 13 Sep 2010 17:23: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: r212563 - in stable/7/sys: kern sys 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, 13 Sep 2010 17:23:19 -0000 Author: mdf Date: Mon Sep 13 17:23:18 2010 New Revision: 212563 URL: http://svn.freebsd.org/changeset/base/212563 Log: MFC r209053: Add INVARIANTS checking that numfreebufs values are sane. Also add a per-buf flag to catch if a buf is double-counted in the free count. This code was useful to debug an instance where a local patch at Isilon was incorrectly managing numfreebufs for a new buf state. Modified: stable/7/sys/kern/vfs_bio.c stable/7/sys/sys/buf.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Mon Sep 13 17:18:49 2010 (r212562) +++ stable/7/sys/kern/vfs_bio.c Mon Sep 13 17:23:18 2010 (r212563) @@ -381,10 +381,16 @@ runningbufwakeup(struct buf *bp) */ static __inline void -bufcountwakeup(void) +bufcountwakeup(struct buf *bp) { + int old; - atomic_add_int(&numfreebuffers, 1); + KASSERT((bp->b_vflags & BV_INFREECNT) == 0, + ("buf %p already counted as free", bp)); + bp->b_vflags |= BV_INFREECNT; + old = atomic_fetchadd_int(&numfreebuffers, 1); + KASSERT(old >= 0 && old < nbuf, + ("numfreebuffers climbed to %d", old + 1)); mtx_lock(&nblock); if (needsbuffer) { needsbuffer &= ~VFS_BIO_NEED_ANY; @@ -587,7 +593,7 @@ bufinit(void) bp->b_rcred = NOCRED; bp->b_wcred = NOCRED; bp->b_qindex = QUEUE_EMPTY; - bp->b_vflags = 0; + bp->b_vflags = BV_INFREECNT; /* buf is counted as free */ bp->b_xflags = 0; LIST_INIT(&bp->b_dep); BUF_LOCKINIT(bp); @@ -688,6 +694,7 @@ bfreekva(struct buf *bp) void bremfree(struct buf *bp) { + int old; CTR3(KTR_BUF, "bremfree(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfree: buf must be locked.")); @@ -698,8 +705,13 @@ bremfree(struct buf *bp) bp->b_flags |= B_REMFREE; /* Fixup numfreebuffers count. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) - atomic_subtract_int(&numfreebuffers, 1); + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { + KASSERT((bp->b_vflags & BV_INFREECNT) != 0, + ("buf %p not counted in numfreebuffers", bp)); + bp->b_vflags &= ~BV_INFREECNT; + old = atomic_fetchadd_int(&numfreebuffers, -1); + KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); + } } /* @@ -725,6 +737,8 @@ bremfreef(struct buf *bp) static void bremfreel(struct buf *bp) { + int old; + CTR3(KTR_BUF, "bremfreel(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfreel: buffer %p not locked.", bp)); @@ -747,8 +761,13 @@ bremfreel(struct buf *bp) * delayed-write, the buffer was free and we must decrement * numfreebuffers. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) - atomic_subtract_int(&numfreebuffers, 1); + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { + KASSERT((bp->b_vflags & BV_INFREECNT) != 0, + ("buf %p not counted in numfreebuffers", bp)); + bp->b_vflags &= ~BV_INFREECNT; + old = atomic_fetchadd_int(&numfreebuffers, -1); + KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); + } } @@ -1452,7 +1471,7 @@ brelse(struct buf *bp) */ if (!(bp->b_flags & B_DELWRI)) - bufcountwakeup(); + bufcountwakeup(bp); /* * Something we can maybe free or reuse @@ -1542,7 +1561,7 @@ bqrelse(struct buf *bp) mtx_unlock(&bqlock); if ((bp->b_flags & B_INVAL) || !(bp->b_flags & B_DELWRI)) - bufcountwakeup(); + bufcountwakeup(bp); /* * Something we can maybe free or reuse. @@ -1922,6 +1941,8 @@ restart: bp->b_flags = 0; bp->b_ioflags = 0; bp->b_xflags = 0; + KASSERT((bp->b_vflags & BV_INFREECNT) == 0, + ("buf %p still counted as free?", bp)); bp->b_vflags = 0; bp->b_vp = NULL; bp->b_blkno = bp->b_lblkno = 0; @@ -4083,4 +4104,27 @@ DB_SHOW_COMMAND(vnodebufs, db_show_vnode db_printf("\n"); } } + +DB_COMMAND(countfreebufs, db_coundfreebufs) +{ + struct buf *bp; + int i, used = 0, nfree = 0; + + if (have_addr) { + db_printf("usage: countfreebufs\n"); + return; + } + + for (i = 0; i < nbuf; i++) { + bp = &buf[i]; + if ((bp->b_vflags & BV_INFREECNT) != 0) + nfree++; + else + used++; + } + + db_printf("Counted %d free, %d used (%d tot)\n", nfree, used, + nfree + used); + db_printf("numfreebuffers is %d\n", numfreebuffers); +} #endif /* DDB */ Modified: stable/7/sys/sys/buf.h ============================================================================== --- stable/7/sys/sys/buf.h Mon Sep 13 17:18:49 2010 (r212562) +++ stable/7/sys/sys/buf.h Mon Sep 13 17:23:18 2010 (r212563) @@ -247,6 +247,7 @@ struct buf { #define BV_SCANNED 0x00000001 /* VOP_FSYNC funcs mark written bufs */ #define BV_BKGRDINPROG 0x00000002 /* Background write in progress */ #define BV_BKGRDWAIT 0x00000004 /* Background write waiting */ +#define BV_INFREECNT 0x80000000 /* buf is counted in numfreebufs */ #ifdef _KERNEL /* From owner-svn-src-stable-7@FreeBSD.ORG Mon Sep 13 17:28:35 2010 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 D9115106566B; Mon, 13 Sep 2010 17:28:35 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7C4A8FC17; Mon, 13 Sep 2010 17:28:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8DHSZCA019093; Mon, 13 Sep 2010 17:28:35 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8DHSZub019091; Mon, 13 Sep 2010 17:28:35 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201009131728.o8DHSZub019091@svn.freebsd.org> From: Glen Barber Date: Mon, 13 Sep 2010 17:28:35 +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: r212565 - stable/7/lib/libc/sys 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, 13 Sep 2010 17:28:36 -0000 Author: gjb (doc committer) Date: Mon Sep 13 17:28:35 2010 New Revision: 212565 URL: http://svn.freebsd.org/changeset/base/212565 Log: MFC 212269. Add ECONNRESET to connect(2). Approved by: keramida (mentor) Modified: stable/7/lib/libc/sys/connect.2 Modified: stable/7/lib/libc/sys/connect.2 ============================================================================== --- stable/7/lib/libc/sys/connect.2 Mon Sep 13 17:27:43 2010 (r212564) +++ stable/7/lib/libc/sys/connect.2 Mon Sep 13 17:28:35 2010 (r212565) @@ -28,7 +28,7 @@ .\" @(#)connect.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd August 16, 2006 +.Dd September 5, 2010 .Dt CONNECT 2 .Os .Sh NAME @@ -95,6 +95,8 @@ The socket is already connected. Connection establishment timed out without establishing a connection. .It Bq Er ECONNREFUSED The attempt to connect was forcefully rejected. +.It Bq Er ECONNRESET +The connection was reset by the remote host. .It Bq Er ENETUNREACH The network is not reachable from this host. .It Bq Er EHOSTUNREACH From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 08:07:58 2010 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 C00221065670; Wed, 15 Sep 2010 08:07:58 +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 B05E28FC24; Wed, 15 Sep 2010 08:07:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8F87wvY026480; Wed, 15 Sep 2010 08:07:58 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8F87wMI026478; Wed, 15 Sep 2010 08:07:58 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201009150807.o8F87wMI026478@svn.freebsd.org> From: Andriy Gapon Date: Wed, 15 Sep 2010 08:07: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: r212640 - stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs 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, 15 Sep 2010 08:07:58 -0000 Author: avg Date: Wed Sep 15 08:07:58 2010 New Revision: 212640 URL: http://svn.freebsd.org/changeset/base/212640 Log: MFC r211762: zfs arc_reclaim_thread: no need to call arc_reclaim_needed when resetting needfree Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Sep 15 08:03:23 2010 (r212639) +++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Sep 15 08:07:58 2010 (r212640) @@ -1990,12 +1990,12 @@ arc_reclaim_thread(void *dummy __unused) if (arc_eviction_list != NULL) arc_do_user_evicts(); - if (arc_reclaim_needed()) { - needfree = 0; #ifdef _KERNEL + if (needfree) { + needfree = 0; wakeup(&needfree); -#endif } +#endif /* block until needed, or one second, whichever is shorter */ CALLB_CPR_SAFE_BEGIN(&cpr); From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 09:38:43 2010 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 78BFF106564A; Wed, 15 Sep 2010 09:38:43 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 696BE8FC1C; Wed, 15 Sep 2010 09:38:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8F9chC1028597; Wed, 15 Sep 2010 09:38:43 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8F9chqF028595; Wed, 15 Sep 2010 09:38:43 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201009150938.o8F9chqF028595@svn.freebsd.org> From: Andre Oppermann Date: Wed, 15 Sep 2010 09:38:43 +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: r212645 - stable/7/sys/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: Wed, 15 Sep 2010 09:38:43 -0000 Author: andre Date: Wed Sep 15 09:38:42 2010 New Revision: 212645 URL: http://svn.freebsd.org/changeset/base/212645 Log: MFC r211874: Use timestamp modulo comparison macro for automatic receive buffer scaling to correctly handle wrapping of ticks value. Modified: stable/7/sys/netinet/tcp_input.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Wed Sep 15 09:38:01 2010 (r212644) +++ stable/7/sys/netinet/tcp_input.c Wed Sep 15 09:38:42 2010 (r212645) @@ -1179,7 +1179,7 @@ tcp_do_segment(struct mbuf *m, struct tc if (tcp_do_autorcvbuf && to.to_tsecr && (so->so_rcv.sb_flags & SB_AUTOSIZE)) { - if (to.to_tsecr > tp->rfbuf_ts && + if (TSTMP_GT(to.to_tsecr, tp->rfbuf_ts) && to.to_tsecr - tp->rfbuf_ts < hz) { if (tp->rfbuf_cnt > (so->so_rcv.sb_hiwat / 8 * 7) && From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 15:33:51 2010 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 E76631065670; Wed, 15 Sep 2010 15:33:51 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D6AE78FC15; Wed, 15 Sep 2010 15:33:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FFXpO3040840; Wed, 15 Sep 2010 15:33:51 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FFXpQS040837; Wed, 15 Sep 2010 15:33:51 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201009151533.o8FFXpQS040837@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 15 Sep 2010 15:33:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212664 - in stable/7/sys: kern sys 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, 15 Sep 2010 15:33:52 -0000 Author: mdf Date: Wed Sep 15 15:33:51 2010 New Revision: 212664 URL: http://svn.freebsd.org/changeset/base/212664 Log: Revert r212563, which was a MFC of r209053, as it introduced an unlocked read/modify/write of b_vflags. The unlocked access is fixed in CURRENT and stable/8 by r211213 and its MFC, r212583. Rather than MFC to stable/7, reverting the injecting code seems preferable. Modified: stable/7/sys/kern/vfs_bio.c stable/7/sys/sys/buf.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Wed Sep 15 15:18:41 2010 (r212663) +++ stable/7/sys/kern/vfs_bio.c Wed Sep 15 15:33:51 2010 (r212664) @@ -381,16 +381,10 @@ runningbufwakeup(struct buf *bp) */ static __inline void -bufcountwakeup(struct buf *bp) +bufcountwakeup(void) { - int old; - KASSERT((bp->b_vflags & BV_INFREECNT) == 0, - ("buf %p already counted as free", bp)); - bp->b_vflags |= BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, 1); - KASSERT(old >= 0 && old < nbuf, - ("numfreebuffers climbed to %d", old + 1)); + atomic_add_int(&numfreebuffers, 1); mtx_lock(&nblock); if (needsbuffer) { needsbuffer &= ~VFS_BIO_NEED_ANY; @@ -593,7 +587,7 @@ bufinit(void) bp->b_rcred = NOCRED; bp->b_wcred = NOCRED; bp->b_qindex = QUEUE_EMPTY; - bp->b_vflags = BV_INFREECNT; /* buf is counted as free */ + bp->b_vflags = 0; bp->b_xflags = 0; LIST_INIT(&bp->b_dep); BUF_LOCKINIT(bp); @@ -694,7 +688,6 @@ bfreekva(struct buf *bp) void bremfree(struct buf *bp) { - int old; CTR3(KTR_BUF, "bremfree(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfree: buf must be locked.")); @@ -705,13 +698,8 @@ bremfree(struct buf *bp) bp->b_flags |= B_REMFREE; /* Fixup numfreebuffers count. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { - KASSERT((bp->b_vflags & BV_INFREECNT) != 0, - ("buf %p not counted in numfreebuffers", bp)); - bp->b_vflags &= ~BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, -1); - KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); - } + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) + atomic_subtract_int(&numfreebuffers, 1); } /* @@ -737,8 +725,6 @@ bremfreef(struct buf *bp) static void bremfreel(struct buf *bp) { - int old; - CTR3(KTR_BUF, "bremfreel(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfreel: buffer %p not locked.", bp)); @@ -761,13 +747,8 @@ bremfreel(struct buf *bp) * delayed-write, the buffer was free and we must decrement * numfreebuffers. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { - KASSERT((bp->b_vflags & BV_INFREECNT) != 0, - ("buf %p not counted in numfreebuffers", bp)); - bp->b_vflags &= ~BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, -1); - KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); - } + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) + atomic_subtract_int(&numfreebuffers, 1); } @@ -1471,7 +1452,7 @@ brelse(struct buf *bp) */ if (!(bp->b_flags & B_DELWRI)) - bufcountwakeup(bp); + bufcountwakeup(); /* * Something we can maybe free or reuse @@ -1561,7 +1542,7 @@ bqrelse(struct buf *bp) mtx_unlock(&bqlock); if ((bp->b_flags & B_INVAL) || !(bp->b_flags & B_DELWRI)) - bufcountwakeup(bp); + bufcountwakeup(); /* * Something we can maybe free or reuse. @@ -1941,8 +1922,6 @@ restart: bp->b_flags = 0; bp->b_ioflags = 0; bp->b_xflags = 0; - KASSERT((bp->b_vflags & BV_INFREECNT) == 0, - ("buf %p still counted as free?", bp)); bp->b_vflags = 0; bp->b_vp = NULL; bp->b_blkno = bp->b_lblkno = 0; @@ -4104,27 +4083,4 @@ DB_SHOW_COMMAND(vnodebufs, db_show_vnode db_printf("\n"); } } - -DB_COMMAND(countfreebufs, db_coundfreebufs) -{ - struct buf *bp; - int i, used = 0, nfree = 0; - - if (have_addr) { - db_printf("usage: countfreebufs\n"); - return; - } - - for (i = 0; i < nbuf; i++) { - bp = &buf[i]; - if ((bp->b_vflags & BV_INFREECNT) != 0) - nfree++; - else - used++; - } - - db_printf("Counted %d free, %d used (%d tot)\n", nfree, used, - nfree + used); - db_printf("numfreebuffers is %d\n", numfreebuffers); -} #endif /* DDB */ Modified: stable/7/sys/sys/buf.h ============================================================================== --- stable/7/sys/sys/buf.h Wed Sep 15 15:18:41 2010 (r212663) +++ stable/7/sys/sys/buf.h Wed Sep 15 15:33:51 2010 (r212664) @@ -247,7 +247,6 @@ struct buf { #define BV_SCANNED 0x00000001 /* VOP_FSYNC funcs mark written bufs */ #define BV_BKGRDINPROG 0x00000002 /* Background write in progress */ #define BV_BKGRDWAIT 0x00000004 /* Background write waiting */ -#define BV_INFREECNT 0x80000000 /* buf is counted in numfreebufs */ #ifdef _KERNEL /* From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 15:55:59 2010 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 26DF21065697; Wed, 15 Sep 2010 15:55:59 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F07678FC19; Wed, 15 Sep 2010 15:55:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FFtwXw041518; Wed, 15 Sep 2010 15:55:58 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FFtwD1041516; Wed, 15 Sep 2010 15:55:58 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201009151555.o8FFtwD1041516@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 15 Sep 2010 15:55: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: r212667 - stable/7/sys/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: Wed, 15 Sep 2010 15:55:59 -0000 Author: mdf Date: Wed Sep 15 15:55:58 2010 New Revision: 212667 URL: http://svn.freebsd.org/changeset/base/212667 Log: MFC r212115: Fix a bug with sched_affinity() where it checks td_pinned of another thread in a racy manner, which can lead to attempting to migrate a thread that is pinned to a CPU. Instead, have sched_switch() determine which CPU a thread should run on if the current one is not allowed. KASSERT in sched_bind() that the thread is not yet pinned to a CPU. KASSERT in sched_switch() that only migratable threads or those moving due to a sched_bind() are changing CPUs. Note that this is direct commit as ipi_cpu() only exists in CURRENT. Modified: stable/7/sys/kern/sched_ule.c Modified: stable/7/sys/kern/sched_ule.c ============================================================================== --- stable/7/sys/kern/sched_ule.c Wed Sep 15 15:53:05 2010 (r212666) +++ stable/7/sys/kern/sched_ule.c Wed Sep 15 15:55:58 2010 (r212667) @@ -1885,10 +1885,16 @@ sched_switch(struct thread *td, struct t srqflag = (flags & SW_PREEMPT) ? SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED : SRQ_OURSELF|SRQ_YIELDING; + if (THREAD_CAN_MIGRATE(td) && !THREAD_CAN_SCHED(td, ts->ts_cpu)) + ts->ts_cpu = sched_pickcpu(td, 0); if (ts->ts_cpu == cpuid) tdq_add(tdq, td, srqflag); - else + else { + KASSERT(THREAD_CAN_MIGRATE(td) || + (ts->ts_flags & TSF_BOUND) != 0, + ("Thread %p shouldn't migrate", td)); mtx = sched_switch_migrate(tdq, td, srqflag); + } } else { /* This thread must be going to sleep. */ TDQ_LOCK(tdq); @@ -2536,7 +2542,6 @@ sched_affinity(struct thread *td) { #ifdef SMP struct td_sched *ts; - int cpu; THREAD_LOCK_ASSERT(td, MA_OWNED); ts = td->td_sched; @@ -2550,17 +2555,13 @@ sched_affinity(struct thread *td) if (!TD_IS_RUNNING(td)) return; td->td_flags |= TDF_NEEDRESCHED; - if (!THREAD_CAN_MIGRATE(td)) - return; /* - * Assign the new cpu and force a switch before returning to - * userspace. If the target thread is not running locally send - * an ipi to force the issue. - */ - cpu = ts->ts_cpu; - ts->ts_cpu = sched_pickcpu(td, 0); - if (cpu != PCPU_GET(cpuid)) - ipi_selected(1 << cpu, IPI_PREEMPT); + * Force a switch before returning to userspace. If the + * target thread is not running locally send an ipi to force + * the issue. + */ + if (td != curthread) + ipi_selected(1 << ts->ts_cpu, IPI_PREEMPT); #endif } @@ -2577,6 +2578,7 @@ sched_bind(struct thread *td, int cpu) ts = td->td_sched; if (ts->ts_flags & TSF_BOUND) sched_unbind(td); + KASSERT(THREAD_CAN_MIGRATE(td), ("%p must be migratable", td)); ts->ts_flags |= TSF_BOUND; #ifdef SMP sched_pin(); From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 17:25:51 2010 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 763821065670; Wed, 15 Sep 2010 17:25:51 +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 651FB8FC08; Wed, 15 Sep 2010 17:25:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FHPpPb044235; Wed, 15 Sep 2010 17:25:51 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FHPpBL044223; Wed, 15 Sep 2010 17:25:51 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201009151725.o8FHPpBL044223@svn.freebsd.org> From: Xin LI Date: Wed, 15 Sep 2010 17:25:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212678 - stable/7/sys/dev/twa 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, 15 Sep 2010 17:25:51 -0000 Author: delphij Date: Wed Sep 15 17:25:51 2010 New Revision: 212678 URL: http://svn.freebsd.org/changeset/base/212678 Log: MFC r212008,212028,212210 the updated twa(4) driver minus maxio change which depends on cam(4) revision r195534. The change have been tested on stable/7 with 3ware 9650SE at iXsystems. Modified: stable/7/sys/dev/twa/tw_cl.h stable/7/sys/dev/twa/tw_cl_externs.h stable/7/sys/dev/twa/tw_cl_fwif.h stable/7/sys/dev/twa/tw_cl_init.c stable/7/sys/dev/twa/tw_cl_intr.c stable/7/sys/dev/twa/tw_cl_io.c stable/7/sys/dev/twa/tw_cl_misc.c stable/7/sys/dev/twa/tw_cl_share.h stable/7/sys/dev/twa/tw_osl.h stable/7/sys/dev/twa/tw_osl_cam.c stable/7/sys/dev/twa/tw_osl_freebsd.c stable/7/sys/dev/twa/tw_osl_share.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/twa/tw_cl.h ============================================================================== --- stable/7/sys/dev/twa/tw_cl.h Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl.h Wed Sep 15 17:25:51 2010 (r212678) @@ -88,7 +88,8 @@ struct tw_cli_q_stats { #define TW_CLI_BUSY_Q 1 /* q of reqs submitted to fw */ #define TW_CLI_PENDING_Q 2 /* q of reqs deferred due to 'q full' */ #define TW_CLI_COMPLETE_Q 3 /* q of reqs completed by fw */ -#define TW_CLI_Q_COUNT 4 /* total number of queues */ +#define TW_CLI_RESET_Q 4 /* q of reqs reset by timeout */ +#define TW_CLI_Q_COUNT 5 /* total number of queues */ /* CL's internal request context. */ @@ -133,6 +134,7 @@ struct tw_cli_ctlr_context { TW_UINT8 interrupts_enabled; /* Interrupts on controller enabled. */ TW_UINT8 internal_req_busy; /* Data buffer for internal requests in use. */ TW_UINT8 get_more_aens; /* More AEN's need to be retrieved. */ + TW_UINT8 reset_needed; /* Controller needs a soft reset. */ TW_UINT8 reset_in_progress; /* Controller is being reset. */ TW_UINT8 reset_phase1_in_progress; /* In 'phase 1' of reset. */ TW_UINT32 flags; /* controller settings */ Modified: stable/7/sys/dev/twa/tw_cl_externs.h ============================================================================== --- stable/7/sys/dev/twa/tw_cl_externs.h Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_externs.h Wed Sep 15 17:25:51 2010 (r212678) @@ -86,6 +86,8 @@ extern TW_INT32 tw_cli_submit_and_poll_r /* Soft reset the controller. */ extern TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr); +extern int twa_setup_intr(struct twa_softc *sc); +extern int twa_teardown_intr(struct twa_softc *sc); /* Send down a SCSI command to the firmware (usually, an internal Req Sense. */ extern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req, Modified: stable/7/sys/dev/twa/tw_cl_fwif.h ============================================================================== --- stable/7/sys/dev/twa/tw_cl_fwif.h Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_fwif.h Wed Sep 15 17:25:51 2010 (r212678) @@ -89,7 +89,7 @@ #define TWA_STATUS_MINOR_VERSION_MASK 0x0F000000 #define TWA_STATUS_MAJOR_VERSION_MASK 0xF0000000 -#define TWA_STATUS_UNEXPECTED_BITS 0x00F00000 +#define TWA_STATUS_UNEXPECTED_BITS 0x00D00000 /* PCI related defines. */ Modified: stable/7/sys/dev/twa/tw_cl_init.c ============================================================================== --- stable/7/sys/dev/twa/tw_cl_init.c Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_init.c Wed Sep 15 17:25:51 2010 (r212678) @@ -315,6 +315,7 @@ tw_cl_init_ctlr(struct tw_cl_ctlr_handle tw_cli_req_q_init(ctlr, TW_CLI_BUSY_Q); tw_cli_req_q_init(ctlr, TW_CLI_PENDING_Q); tw_cli_req_q_init(ctlr, TW_CLI_COMPLETE_Q); + tw_cli_req_q_init(ctlr, TW_CLI_RESET_Q); /* Initialize all locks used by CL. */ ctlr->gen_lock = &(ctlr->gen_lock_handle); @@ -675,15 +676,14 @@ tw_cli_init_connection(struct tw_cli_ctl /* Submit the command, and wait for it to complete. */ error = tw_cli_submit_and_poll_request(req, TW_CLI_REQUEST_TIMEOUT_PERIOD); - if (error == TW_OSL_ETIMEDOUT) - /* Clean-up done by tw_cli_submit_and_poll_request. */ - return(error); if (error) goto out; if ((error = init_connect->status)) { +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, &(req->cmd_pkt->cmd_hdr)); +#endif // 0 goto out; } if (set_features & TWA_EXTENDED_INIT_CONNECT) { Modified: stable/7/sys/dev/twa/tw_cl_intr.c ============================================================================== --- stable/7/sys/dev/twa/tw_cl_intr.c Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_intr.c Wed Sep 15 17:25:51 2010 (r212678) @@ -248,8 +248,7 @@ tw_cli_process_resp_intr(struct tw_cli_c #ifdef TW_OSL_DEBUG tw_cl_print_ctlr_stats(ctlr->ctlr_handle); #endif /* TW_OSL_DEBUG */ - tw_cl_reset_ctlr(ctlr->ctlr_handle); - return(TW_OSL_EIO); + continue; } /* @@ -402,9 +401,7 @@ tw_cli_complete_io(struct tw_cli_req_con #ifdef TW_OSL_DEBUG tw_cl_print_ctlr_stats(ctlr->ctlr_handle); #endif /* TW_OSL_DEBUG */ - tw_cl_reset_ctlr(ctlr->ctlr_handle); - req_pkt->status = TW_CL_ERR_REQ_BUS_RESET; - goto out; + return; } if (req->flags & TW_CLI_REQ_FLAGS_PASSTHRU) { @@ -483,6 +480,7 @@ tw_cli_scsi_complete(struct tw_cli_req_c cdb[8], cdb[9], cdb[10], cdb[11], cdb[12], cdb[13], cdb[14], cdb[15]); +#if 0 /* * Print the error. Firmware doesn't yet support * the 'Mode Sense' cmd. Don't print if the cmd @@ -493,6 +491,7 @@ tw_cli_scsi_complete(struct tw_cli_req_c tw_cli_create_ctlr_event(req->ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, cmd_hdr); +#endif // 0 } if (scsi_req->sense_data) { @@ -530,9 +529,11 @@ tw_cli_param_callback(struct tw_cli_req_ */ if (! req->error_code) if (cmd->param.status) { +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, &(req->cmd_pkt->cmd_hdr)); +#endif // 0 tw_cl_create_event(ctlr->ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_ERROR, 0x1204, 0x1, TW_CL_SEVERITY_ERROR_STRING, @@ -590,9 +591,11 @@ tw_cli_aen_callback(struct tw_cli_req_co if ((error = cmd->status)) { cmd_hdr = (struct tw_cl_command_header *) (&(req->cmd_pkt->cmd_hdr)); +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, cmd_hdr); +#endif // 0 tw_cl_create_event(ctlr->ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_ERROR, 0x1206, 0x1, TW_CL_SEVERITY_ERROR_STRING, Modified: stable/7/sys/dev/twa/tw_cl_io.c ============================================================================== --- stable/7/sys/dev/twa/tw_cl_io.c Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_io.c Wed Sep 15 17:25:51 2010 (r212678) @@ -74,18 +74,12 @@ tw_cl_start_io(struct tw_cl_ctlr_handle struct tw_cli_req_context *req; struct tw_cl_command_9k *cmd; struct tw_cl_scsi_req_packet *scsi_req; - TW_INT32 error; + TW_INT32 error = TW_CL_ERR_REQ_SUCCESS; tw_cli_dbg_printf(10, ctlr_handle, tw_osl_cur_func(), "entered"); ctlr = (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); - if (ctlr->reset_in_progress) { - tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), - "I/O during reset: returning busy."); - return(TW_OSL_EBUSY); - } - /* * If working with a firmware version that does not support multiple * luns, and this request is directed at a non-zero lun, error it @@ -145,7 +139,12 @@ tw_cl_start_io(struct tw_cl_ctlr_handle cmd->sg_list, scsi_req->sgl_entries); } - if ((error = tw_cli_submit_cmd(req))) { + if (((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL) || + (ctlr->reset_in_progress)) { + tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q); + TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, + TWA_CONTROL_UNMASK_COMMAND_INTERRUPT); + } else if ((error = tw_cli_submit_cmd(req))) { tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), "Could not start request. request = %p, error = %d", req, error); @@ -171,7 +170,7 @@ tw_cli_submit_cmd(struct tw_cli_req_cont struct tw_cli_ctlr_context *ctlr = req->ctlr; struct tw_cl_ctlr_handle *ctlr_handle = ctlr->ctlr_handle; TW_UINT32 status_reg; - TW_INT32 error; + TW_INT32 error = 0; tw_cli_dbg_printf(10, ctlr_handle, tw_osl_cur_func(), "entered"); @@ -185,11 +184,7 @@ tw_cli_submit_cmd(struct tw_cli_req_cont TWA_COMMAND_QUEUE_OFFSET_LOW, (TW_UINT32)(req->cmd_pkt_phys + sizeof(struct tw_cl_command_header)), 4); - /* Check to see if we can post a command. */ status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr_handle); - if ((error = tw_cli_check_ctlr_state(ctlr, status_reg))) - goto out; - if (status_reg & TWA_STATUS_COMMAND_QUEUE_FULL) { struct tw_cl_req_packet *req_pkt = (struct tw_cl_req_packet *)(req->orig_req); @@ -207,14 +202,12 @@ tw_cli_submit_cmd(struct tw_cli_req_cont "pending internal/ioctl request"); req->state = TW_CLI_REQ_STATE_PENDING; tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q); - error = 0; /* Unmask command interrupt. */ TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, TWA_CONTROL_UNMASK_COMMAND_INTERRUPT); } else error = TW_OSL_EBUSY; } else { - tw_osl_ctlr_busy(ctlr_handle, req->req_handle); error = TW_OSL_EBUSY; } } else { @@ -246,7 +239,7 @@ tw_cli_submit_cmd(struct tw_cli_req_cont (TW_UINT32)(req->cmd_pkt_phys + sizeof(struct tw_cl_command_header)), 4); } } -out: + tw_osl_free_lock(ctlr_handle, ctlr->io_lock); return(error); @@ -277,18 +270,12 @@ tw_cl_fw_passthru(struct tw_cl_ctlr_hand TW_UINT8 opcode; TW_UINT8 sgl_offset; TW_VOID *sgl = TW_CL_NULL; - TW_INT32 error; + TW_INT32 error = TW_CL_ERR_REQ_SUCCESS; tw_cli_dbg_printf(5, ctlr_handle, tw_osl_cur_func(), "entered"); ctlr = (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); - if (ctlr->reset_in_progress) { - tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), - "Passthru request during reset: returning busy."); - return(TW_OSL_EBUSY); - } - if ((req = tw_cli_get_request(ctlr )) == TW_CL_NULL) { tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), @@ -301,7 +288,7 @@ tw_cl_fw_passthru(struct tw_cl_ctlr_hand req->orig_req = req_pkt; req->tw_cli_callback = tw_cli_complete_io; - req->flags |= (TW_CLI_REQ_FLAGS_EXTERNAL | TW_CLI_REQ_FLAGS_PASSTHRU); + req->flags |= TW_CLI_REQ_FLAGS_PASSTHRU; pt_req = &(req_pkt->gen_req_pkt.pt_req); @@ -348,7 +335,12 @@ tw_cl_fw_passthru(struct tw_cl_ctlr_hand tw_cli_fill_sg_list(ctlr, pt_req->sg_list, sgl, pt_req->sgl_entries); - if ((error = tw_cli_submit_cmd(req))) { + if (((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL) || + (ctlr->reset_in_progress)) { + tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q); + TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, + TWA_CONTROL_UNMASK_COMMAND_INTERRUPT); + } else if ((error = tw_cli_submit_cmd(req))) { tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_ERROR, 0x1100, 0x1, TW_CL_SEVERITY_ERROR_STRING, @@ -760,8 +752,7 @@ tw_cli_get_param(struct tw_cli_ctlr_cont cmd->param.sgl_off__opcode = BUILD_SGL_OFF__OPCODE(2, TWA_FW_CMD_GET_PARAM); - cmd->param.request_id = - (TW_UINT8)(TW_CL_SWAP16(req->request_id)); + cmd->param.request_id = (TW_UINT8)(TW_CL_SWAP16(req->request_id)); cmd->param.host_id__unit = BUILD_HOST_ID__UNIT(0, 0); cmd->param.param_count = TW_CL_SWAP16(1); @@ -789,15 +780,14 @@ tw_cli_get_param(struct tw_cli_ctlr_cont /* There's no call back; wait till the command completes. */ error = tw_cli_submit_and_poll_request(req, TW_CLI_REQUEST_TIMEOUT_PERIOD); - if (error == TW_OSL_ETIMEDOUT) - /* Clean-up done by tw_cli_submit_and_poll_request. */ - return(error); if (error) goto out; if ((error = cmd->param.status)) { +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, &(req->cmd_pkt->cmd_hdr)); +#endif // 0 goto out; } tw_osl_memcpy(param_data, param->data, param_size); @@ -905,18 +895,17 @@ tw_cli_set_param(struct tw_cli_ctlr_cont /* Submit the command. */ if (callback == TW_CL_NULL) { - /* There's no call back; wait till the command completes. */ + /* There's no call back; wait till the command completes. */ error = tw_cli_submit_and_poll_request(req, - TW_CLI_REQUEST_TIMEOUT_PERIOD); - if (error == TW_OSL_ETIMEDOUT) - /* Clean-up done by tw_cli_submit_and_poll_request. */ - return(error); + TW_CLI_REQUEST_TIMEOUT_PERIOD); if (error) goto out; if ((error = cmd->param.status)) { +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, &(req->cmd_pkt->cmd_hdr)); +#endif // 0 goto out; } ctlr->internal_req_busy = TW_CL_FALSE; @@ -1022,9 +1011,7 @@ tw_cli_submit_and_poll_request(struct tw * tw_cli_submit_pending_queue. There could be a race in that case. * Need to revisit. */ - if (req->state != TW_CLI_REQ_STATE_PENDING) - tw_cl_reset_ctlr(ctlr->ctlr_handle); - else { + if (req->state == TW_CLI_REQ_STATE_PENDING) { tw_cli_dbg_printf(3, ctlr->ctlr_handle, tw_osl_cur_func(), "Removing request from pending queue"); /* @@ -1053,6 +1040,7 @@ tw_cli_submit_and_poll_request(struct tw * drains any incomplete requests. * * Input: ctlr -- ptr to per ctlr structure + * req_handle -- ptr to request handle * Output: None * Return value: 0 -- success * non-zero-- failure @@ -1063,15 +1051,15 @@ tw_cl_reset_ctlr(struct tw_cl_ctlr_handl struct tw_cli_ctlr_context *ctlr = (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); struct twa_softc *sc = ctlr_handle->osl_ctlr_ctxt; + struct tw_cli_req_context *req; TW_INT32 reset_attempt = 1; - TW_INT32 error; + TW_INT32 error = 0; tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), "entered"); ctlr->reset_in_progress = TW_CL_TRUE; - xpt_freeze_simq(sc->sim, 1); + twa_teardown_intr(sc); - tw_cli_disable_interrupts(ctlr); /* * Error back all requests in the complete, busy, and pending queues. @@ -1080,8 +1068,6 @@ tw_cl_reset_ctlr(struct tw_cl_ctlr_handl * will continue its course and get submitted to the controller after * the reset is done (and io_lock is released). */ - tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(), - "Draining all queues following reset"); tw_cli_drain_complete_queue(ctlr); tw_cli_drain_busy_queue(ctlr); tw_cli_drain_pending_queue(ctlr); @@ -1089,53 +1075,88 @@ tw_cl_reset_ctlr(struct tw_cl_ctlr_handl ctlr->get_more_aens = TW_CL_FALSE; /* Soft reset the controller. */ -try_reset: - if ((error = tw_cli_soft_reset(ctlr))) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, - 0x1105, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Controller reset failed", - "error = %d; attempt %d", error, reset_attempt++); - if (reset_attempt <= TW_CLI_MAX_RESET_ATTEMPTS) - goto try_reset; - else - goto out; - } + while (reset_attempt <= TW_CLI_MAX_RESET_ATTEMPTS) { + if ((error = tw_cli_soft_reset(ctlr))) { + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, + TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, + 0x1105, 0x1, TW_CL_SEVERITY_ERROR_STRING, + "Controller reset failed", + "error = %d; attempt %d", error, reset_attempt++); + reset_attempt++; + continue; + } - /* Re-establish logical connection with the controller. */ - if ((error = tw_cli_init_connection(ctlr, - (TW_UINT16)(ctlr->max_simult_reqs), - 0, 0, 0, 0, 0, TW_CL_NULL, TW_CL_NULL, TW_CL_NULL, - TW_CL_NULL, TW_CL_NULL))) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + /* Re-establish logical connection with the controller. */ + if ((error = tw_cli_init_connection(ctlr, + (TW_UINT16)(ctlr->max_simult_reqs), + 0, 0, 0, 0, 0, TW_CL_NULL, TW_CL_NULL, TW_CL_NULL, + TW_CL_NULL, TW_CL_NULL))) { + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, + TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, + 0x1106, 0x1, TW_CL_SEVERITY_ERROR_STRING, + "Can't initialize connection after reset", + "error = %d", error); + reset_attempt++; + continue; + } + +#ifdef TW_OSL_DEBUG + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, - 0x1106, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Can't initialize connection after reset", - "error = %d", error); - goto out; - } + 0x1107, 0x3, TW_CL_SEVERITY_INFO_STRING, + "Controller reset done!", " "); +#endif /* TW_OSL_DEBUG */ + break; + } /* End of while */ - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, - 0x1107, 0x3, TW_CL_SEVERITY_INFO_STRING, - "Controller reset done!", - " "); + /* Move commands from the reset queue to the pending queue. */ + while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_RESET_Q)) != TW_CL_NULL) { + tw_osl_timeout(req->req_handle); + tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q); + } -out: + twa_setup_intr(sc); + tw_cli_enable_interrupts(ctlr); + if ((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL) + TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, + TWA_CONTROL_UNMASK_COMMAND_INTERRUPT); ctlr->reset_in_progress = TW_CL_FALSE; - xpt_release_simq(sc->sim, 1); + ctlr->reset_needed = TW_CL_FALSE; - /* - * Enable interrupts, and also clear attention and response interrupts. - */ - tw_cli_enable_interrupts(ctlr); - /* Request for a bus re-scan. */ - if (!error) - tw_osl_scan_bus(ctlr_handle); + tw_osl_scan_bus(ctlr_handle); + return(error); } +TW_VOID +tw_cl_set_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle) +{ + struct tw_cli_ctlr_context *ctlr = + (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); + + ctlr->reset_needed = TW_CL_TRUE; +} + +TW_INT32 +tw_cl_is_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle) +{ + struct tw_cli_ctlr_context *ctlr = + (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); + + return(ctlr->reset_needed); +} + +TW_INT32 +tw_cl_is_active(struct tw_cl_ctlr_handle *ctlr_handle) +{ + struct tw_cli_ctlr_context *ctlr = + (struct tw_cli_ctlr_context *) + (ctlr_handle->cl_ctlr_ctxt); + + return(ctlr->active); +} + /* @@ -1151,14 +1172,13 @@ TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr) { struct tw_cl_ctlr_handle *ctlr_handle = ctlr->ctlr_handle; - TW_UINT32 status_reg; int found; int loop_count; TW_UINT32 error; tw_cli_dbg_printf(1, ctlr_handle, tw_osl_cur_func(), "entered"); - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1108, 0x3, TW_CL_SEVERITY_INFO_STRING, "Resetting controller...", @@ -1193,7 +1213,7 @@ tw_cli_soft_reset(struct tw_cli_ctlr_con } while (!found && (loop_count < 6000000)); /* Loop for no more than 60 seconds */ if (!found) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1109, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Missed firmware handshake after soft-reset", @@ -1210,7 +1230,7 @@ tw_cli_soft_reset(struct tw_cli_ctlr_con TWA_STATUS_MICROCONTROLLER_READY | TWA_STATUS_ATTENTION_INTERRUPT, TW_CLI_RESET_TIMEOUT_PERIOD))) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1109, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Micro-ctlr not ready/No attn intr after reset", @@ -1244,26 +1264,14 @@ tw_cli_soft_reset(struct tw_cli_ctlr_con } if ((error = tw_cli_find_aen(ctlr, TWA_AEN_SOFT_RESET))) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x110C, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Reset not reported by controller", "error = %d", error); return(error); } - - status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr_handle); - - if ((error = TW_CLI_STATUS_ERRORS(status_reg)) || - (error = tw_cli_check_ctlr_state(ctlr, status_reg))) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, - 0x110D, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Controller errors detected after reset", - "error = %d", error); - return(error); - } - + return(TW_OSL_ESUCCESS); } Modified: stable/7/sys/dev/twa/tw_cl_misc.c ============================================================================== --- stable/7/sys/dev/twa/tw_cl_misc.c Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_misc.c Wed Sep 15 17:25:51 2010 (r212678) @@ -83,7 +83,8 @@ tw_cli_drain_complete_queue(struct tw_cl tw_cli_dbg_printf(3, ctlr->ctlr_handle, tw_osl_cur_func(), "entered"); /* Walk the busy queue. */ - while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_COMPLETE_Q))) { + while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_COMPLETE_Q)) != + TW_CL_NULL) { if (req->flags & TW_CLI_REQ_FLAGS_INTERNAL) { /* * It's an internal request. Set the appropriate @@ -97,20 +98,21 @@ tw_cli_drain_complete_queue(struct tw_cl req->error_code = TW_CL_ERR_REQ_BUS_RESET; if (req->tw_cli_callback) req->tw_cli_callback(req); - } else { - if ((req_pkt = req->orig_req)) { - /* It's a SCSI request. Complete it. */ - tw_cli_dbg_printf(2, ctlr->ctlr_handle, - tw_osl_cur_func(), - "Completing complete request %p " - "on reset", - req); + } else if (req->flags & TW_CLI_REQ_FLAGS_PASSTHRU) { + /* It's a passthru request. Complete it. */ + if ((req_pkt = req->orig_req) != TW_CL_NULL) { req_pkt->status = TW_CL_ERR_REQ_BUS_RESET; - req_pkt->tw_osl_callback(req->req_handle); + + if (req_pkt->tw_osl_callback) + req_pkt->tw_osl_callback(req->req_handle); } tw_cli_req_q_insert_tail(req, TW_CLI_FREE_Q); + } else { + /* It's an external (SCSI) request. Add it to the reset queue. */ + tw_osl_untimeout(req->req_handle); + tw_cli_req_q_insert_tail(req, TW_CLI_RESET_Q); } - } + } /* End of while loop */ } @@ -135,7 +137,8 @@ tw_cli_drain_busy_queue(struct tw_cli_ct tw_cli_dbg_printf(3, ctlr->ctlr_handle, tw_osl_cur_func(), "entered"); /* Walk the busy queue. */ - while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_BUSY_Q))) { + while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_BUSY_Q)) != + TW_CL_NULL) { if (req->flags & TW_CLI_REQ_FLAGS_INTERNAL) { /* * It's an internal request. Set the appropriate @@ -149,19 +152,21 @@ tw_cli_drain_busy_queue(struct tw_cli_ct req->error_code = TW_CL_ERR_REQ_BUS_RESET; if (req->tw_cli_callback) req->tw_cli_callback(req); - } else { - if ((req_pkt = req->orig_req)) { - /* It's a SCSI request. Complete it. */ - tw_cli_dbg_printf(2, ctlr->ctlr_handle, - tw_osl_cur_func(), - "Completing busy request %p on reset", - req); + } else if (req->flags & TW_CLI_REQ_FLAGS_PASSTHRU) { + /* It's a passthru request. Complete it. */ + if ((req_pkt = req->orig_req) != TW_CL_NULL) { req_pkt->status = TW_CL_ERR_REQ_BUS_RESET; - req_pkt->tw_osl_callback(req->req_handle); + + if (req_pkt->tw_osl_callback) + req_pkt->tw_osl_callback(req->req_handle); } tw_cli_req_q_insert_tail(req, TW_CLI_FREE_Q); + } else { + /* It's an external (SCSI) request. Add it to the reset queue. */ + tw_osl_untimeout(req->req_handle); + tw_cli_req_q_insert_tail(req, TW_CLI_RESET_Q); } - } + } /* End of while loop */ } @@ -188,7 +193,8 @@ tw_cli_drain_pending_queue(struct tw_cli /* * Pull requests off the pending queue, and complete them. */ - while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_PENDING_Q))) { + while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_PENDING_Q)) != + TW_CL_NULL) { if (req->flags & TW_CLI_REQ_FLAGS_INTERNAL) { /* * It's an internal request. Set the appropriate @@ -202,19 +208,21 @@ tw_cli_drain_pending_queue(struct tw_cli req->error_code = TW_CL_ERR_REQ_BUS_RESET; if (req->tw_cli_callback) req->tw_cli_callback(req); - } else { - if ((req_pkt = req->orig_req)) { - /* It's an external request. Complete it. */ - tw_cli_dbg_printf(2, ctlr->ctlr_handle, - tw_osl_cur_func(), - "Completing pending request %p " - "on reset", req); + } else if (req->flags & TW_CLI_REQ_FLAGS_PASSTHRU) { + /* It's a passthru request. Complete it. */ + if ((req_pkt = req->orig_req) != TW_CL_NULL) { req_pkt->status = TW_CL_ERR_REQ_BUS_RESET; - req_pkt->tw_osl_callback(req->req_handle); + + if (req_pkt->tw_osl_callback) + req_pkt->tw_osl_callback(req->req_handle); } tw_cli_req_q_insert_tail(req, TW_CLI_FREE_Q); + } else { + /* It's an external (SCSI) request. Add it to the reset queue. */ + tw_osl_untimeout(req->req_handle); + tw_cli_req_q_insert_tail(req, TW_CLI_RESET_Q); } - } + } /* End of while loop */ } @@ -239,9 +247,6 @@ tw_cli_drain_response_queue(struct tw_cl for (;;) { status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr->ctlr_handle); - if (tw_cli_check_ctlr_state(ctlr, status_reg)) - return(TW_OSL_EGENFAILURE); - if (status_reg & TWA_STATUS_RESPONSE_QUEUE_EMPTY) return(TW_OSL_ESUCCESS); /* no more response queue entries */ @@ -273,9 +278,6 @@ tw_cli_find_response(struct tw_cli_ctlr_ for (;;) { status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr->ctlr_handle); - if (tw_cli_check_ctlr_state(ctlr, status_reg)) - return(TW_OSL_EGENFAILURE); - if (status_reg & TWA_STATUS_RESPONSE_QUEUE_EMPTY) return(TW_OSL_ENOTTY); /* no more response queue entries */ @@ -356,9 +358,11 @@ tw_cli_drain_aen_queue(struct tw_cli_ctl if ((error = req->cmd_pkt->command.cmd_pkt_9k.status)) { cmd_hdr = &req->cmd_pkt->cmd_hdr; +#if 0 tw_cli_create_ctlr_event(ctlr, TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR, cmd_hdr); +#endif // 0 break; } @@ -714,7 +718,7 @@ tw_cli_check_ctlr_state(struct tw_cli_ct tw_osl_memzero(desc, 200); if (!(ctlr->reset_phase1_in_progress)) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1301, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Missing expected status bit(s)", @@ -738,7 +742,7 @@ tw_cli_check_ctlr_state(struct tw_cli_ct (ctlr->device_id != TW_CL_DEVICE_ID_9K_SA)) || (!(ctlr->reset_in_progress)) || ((status_reg & TWA_STATUS_QUEUE_ERROR_INTERRUPT) == 0)) - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1302, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Unexpected status bit(s)", @@ -748,7 +752,7 @@ tw_cli_check_ctlr_state(struct tw_cli_ct TWA_STATUS_UNEXPECTED_BITS, desc)); if (status_reg & TWA_STATUS_PCI_PARITY_ERROR_INTERRUPT) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1303, 0x1, TW_CL_SEVERITY_ERROR_STRING, "PCI parity error: clearing... " @@ -768,7 +772,7 @@ tw_cli_check_ctlr_state(struct tw_cli_ct } if (status_reg & TWA_STATUS_PCI_ABORT_INTERRUPT) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1304, 0x1, TW_CL_SEVERITY_ERROR_STRING, "PCI abort: clearing... ", @@ -791,7 +795,7 @@ tw_cli_check_ctlr_state(struct tw_cli_ct if (((ctlr->device_id != TW_CL_DEVICE_ID_9K_E) && (ctlr->device_id != TW_CL_DEVICE_ID_9K_SA)) || (!(ctlr->reset_in_progress))) - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, + tw_cl_create_event(ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, 0x1305, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Controller queue error: clearing... ", @@ -801,17 +805,6 @@ tw_cli_check_ctlr_state(struct tw_cli_ct TW_CLI_WRITE_CONTROL_REGISTER(ctlr->ctlr_handle, TWA_CONTROL_CLEAR_QUEUE_ERROR); } - - if (status_reg & TWA_STATUS_MICROCONTROLLER_ERROR) { - tw_cl_create_event(ctlr_handle, TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT, - 0x1307, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Micro-controller error! ", - "status reg = 0x%x %s", - status_reg, - tw_cli_describe_bits(status_reg, desc)); - error = TW_OSL_EGENFAILURE; - } } return(error); } @@ -850,8 +843,6 @@ tw_cli_describe_bits(TW_UINT32 reg, TW_I tw_osl_strcpy(&str[tw_osl_strlen(str)], "HOST_INTR,"); if (reg & TWA_STATUS_PCI_ABORT_INTERRUPT) tw_osl_strcpy(&str[tw_osl_strlen(str)], "PCI_ABRT,"); - if (reg & TWA_STATUS_MICROCONTROLLER_ERROR) - tw_osl_strcpy(&str[tw_osl_strlen(str)], "MC_ERR,"); if (reg & TWA_STATUS_QUEUE_ERROR_INTERRUPT) tw_osl_strcpy(&str[tw_osl_strlen(str)], "Q_ERR,"); if (reg & TWA_STATUS_PCI_PARITY_ERROR_INTERRUPT) Modified: stable/7/sys/dev/twa/tw_cl_share.h ============================================================================== --- stable/7/sys/dev/twa/tw_cl_share.h Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_cl_share.h Wed Sep 15 17:25:51 2010 (r212678) @@ -349,10 +349,14 @@ extern TW_VOID tw_osl_breakpoint(TW_VOID #endif -#ifndef tw_osl_ctlr_busy -/* Called when CL is too busy to accept new requests. */ -extern TW_VOID tw_osl_ctlr_busy(struct tw_cl_ctlr_handle *ctlr_handle, - struct tw_cl_req_handle *req_handle); +#ifndef tw_osl_timeout +/* Start OS timeout() routine after controller reset sequence */ +extern TW_VOID tw_osl_timeout(struct tw_cl_req_handle *req_handle); +#endif + +#ifndef tw_osl_untimeout +/* Stop OS timeout() routine during controller reset sequence */ +extern TW_VOID tw_osl_untimeout(struct tw_cl_req_handle *req_handle); #endif @@ -552,6 +556,10 @@ extern TW_INT32 tw_cl_init_ctlr(struct t ); +extern TW_VOID tw_cl_set_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle); +extern TW_INT32 tw_cl_is_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle); +extern TW_INT32 tw_cl_is_active(struct tw_cl_ctlr_handle *ctlr_handle); + /* CL's interrupt handler. */ extern TW_INT32 tw_cl_interrupt(struct tw_cl_ctlr_handle *ctlr_handle); Modified: stable/7/sys/dev/twa/tw_osl.h ============================================================================== --- stable/7/sys/dev/twa/tw_osl.h Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_osl.h Wed Sep 15 17:25:51 2010 (r212678) @@ -77,6 +77,7 @@ EINPROGRESS */ #define TW_OSLI_REQ_FLAGS_PASSTHRU (1<<5) /* pass through request */ #define TW_OSLI_REQ_FLAGS_SLEEPING (1<<6) /* owner sleeping on this cmd */ +#define TW_OSLI_REQ_FLAGS_FAILED (1<<7) /* bus_dmamap_load() failed */ #ifdef TW_OSL_DEBUG @@ -100,6 +101,7 @@ struct tw_osli_req_context { struct twa_softc *ctlr; /* ptr to OSL's controller context */ TW_VOID *data; /* ptr to data being passed to CL */ TW_UINT32 length; /* length of buf being passed to CL */ + TW_UINT64 deadline;/* request timeout (in absolute time) */ /* * ptr to, and length of data passed to us from above, in case a buffer @@ -151,6 +153,9 @@ struct twa_softc { struct mtx sim_lock_handle;/* sim lock shared with cam */ struct mtx *sim_lock;/* ptr to sim lock */ + struct callout watchdog_callout[2]; /* For command timout */ + TW_UINT32 watchdog_index; + #ifdef TW_OSL_DEBUG struct tw_osli_q_stats q_stats[TW_OSLI_Q_COUNT];/* queue statistics */ #endif /* TW_OSL_DEBUG */ Modified: stable/7/sys/dev/twa/tw_osl_cam.c ============================================================================== --- stable/7/sys/dev/twa/tw_osl_cam.c Wed Sep 15 17:25:09 2010 (r212677) +++ stable/7/sys/dev/twa/tw_osl_cam.c Wed Sep 15 17:25:51 2010 (r212678) @@ -55,7 +55,6 @@ static TW_VOID twa_action(struct cam_sim *sim, union ccb *ccb); static TW_VOID twa_poll(struct cam_sim *sim); -static TW_VOID twa_timeout(TW_VOID *arg); static TW_VOID twa_bus_scan_cb(struct cam_periph *periph, union ccb *ccb); static TW_INT32 tw_osli_execute_scsi(struct tw_osli_req_context *req, @@ -83,7 +82,7 @@ tw_osli_cam_attach(struct twa_softc *sc) /* * Create the device queue for our SIM. */ - if ((devq = cam_simq_alloc(TW_OSLI_MAX_NUM_REQUESTS)) == NULL) { + if ((devq = cam_simq_alloc(TW_OSLI_MAX_NUM_IOS)) == NULL) { tw_osli_printf(sc, "error = %d", TW_CL_SEVERITY_ERROR_STRING, TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, @@ -292,6 +291,7 @@ tw_osli_execute_scsi(struct tw_osli_req_ "I/O size too big", csio->dxfer_len); ccb_h->status = CAM_REQ_TOO_BIG; + ccb_h->status &= ~CAM_SIM_QUEUED; xpt_done(ccb); return(1); } @@ -307,6 +307,7 @@ tw_osli_execute_scsi(struct tw_osli_req_ 0x2107, "XPT_SCSI_IO: Got SGList"); ccb_h->status = CAM_REQ_INVALID; + ccb_h->status &= ~CAM_SIM_QUEUED; xpt_done(ccb); return(1); } @@ -323,13 +324,20 @@ tw_osli_execute_scsi(struct tw_osli_req_ return(1); } - ccb_h->timeout_ch = timeout(twa_timeout, req, - (ccb_h->timeout * hz) / 1000); + req->deadline = tw_osl_get_local_time() + (ccb_h->timeout / 1000); + + /* * twa_map_load_data_callback will fill in the SGL, * and submit the I/O. */ error = tw_osli_map_request(req); + if ((error) && (req->flags & TW_OSLI_REQ_FLAGS_FAILED)) { + req->deadline = 0; + ccb_h->status = CAM_REQ_CMP_ERR; + ccb_h->status &= ~CAM_SIM_QUEUED; + xpt_done(ccb); + } return(error); } @@ -362,10 +370,20 @@ twa_action(struct cam_sim *sim, union cc * Freeze the simq to maintain ccb ordering. The next * ccb that gets completed will unfreeze the simq. */ + ccb_h->status &= ~CAM_SIM_QUEUED; ccb_h->status |= CAM_REQUEUE_REQ; xpt_done(ccb); break; } + + if ((tw_cl_is_reset_needed(&(req->ctlr->ctlr_handle)))) { + ccb_h->status &= ~CAM_SIM_QUEUED; + ccb_h->status |= CAM_REQUEUE_REQ; + xpt_done(ccb); + tw_osli_req_q_insert_tail(req, TW_OSLI_FREE_Q); + break; + } + req->req_handle.osl_req_ctxt = req; req->req_handle.is_io = TW_CL_TRUE; req->orig_req = ccb; @@ -381,25 +399,14 @@ twa_action(struct cam_sim *sim, union cc break; case XPT_RESET_BUS: - tw_cl_create_event(&(sc->ctlr_handle), TW_CL_TRUE, + tw_cl_create_event(&(sc->ctlr_handle), TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, 0x2108, 0x3, TW_CL_SEVERITY_INFO_STRING, "Received Reset Bus request from CAM", " "); - mtx_unlock(sc->sim_lock); - if (tw_cl_reset_ctlr(&sc->ctlr_handle)) { - tw_cl_create_event(&(sc->ctlr_handle), TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, - 0x2109, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Failed to reset bus", - " "); - ccb_h->status = CAM_REQ_CMP_ERR; - } - else - ccb_h->status = CAM_REQ_CMP; - - mtx_lock(sc->sim_lock); + tw_cl_set_reset_needed(&(sc->ctlr_handle)); + ccb_h->status = CAM_REQ_CMP; xpt_done(ccb); break; @@ -504,31 +511,6 @@ twa_poll(struct cam_sim *sim) /* - * Function name: twa_timeout - * Description: Driver entry point for being alerted on a request - * timing out. - * - * Input: arg -- ptr to timed out request - * Output: None - * Return value: None - */ -static TW_VOID -twa_timeout(TW_VOID *arg) -{ - struct tw_osli_req_context *req = - (struct tw_osli_req_context *)arg; - - tw_cl_create_event(&(req->ctlr->ctlr_handle), TW_CL_TRUE, - TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, - 0x210B, 0x1, TW_CL_SEVERITY_ERROR_STRING, - "Request timed out!", - "request = %p", req); - tw_cl_reset_ctlr(&(req->ctlr->ctlr_handle)); -} - - - -/* * Function name: tw_osli_request_bus_scan * Description: Requests CAM for a scan of the bus. * @@ -623,20 +605,39 @@ tw_osli_disallow_new_requests(struct twa /* - * Function name: tw_osl_ctlr_busy - * Description: CL calls this function on cmd queue full or otherwise, - * when it is too busy to accept new requests. + * Function name: tw_osl_timeout + * Description: Call to timeout(). * - * Input: ctlr_handle -- ptr to controller handle - * req_handle -- ptr to request handle sent by OSL. + * Input: req_handle -- ptr to request handle sent by OSL. * Output: None * Return value: None */ TW_VOID -tw_osl_ctlr_busy(struct tw_cl_ctlr_handle *ctlr_handle, - struct tw_cl_req_handle *req_handle) +tw_osl_timeout(struct tw_cl_req_handle *req_handle) +{ + struct tw_osli_req_context *req = req_handle->osl_req_ctxt; + union ccb *ccb = (union ccb *)(req->orig_req); + struct ccb_hdr *ccb_h = &(ccb->ccb_h); + + req->deadline = tw_osl_get_local_time() + (ccb_h->timeout / 1000); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 17:39:15 2010 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 96433106566C; Wed, 15 Sep 2010 17:39:15 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C1008FC18; Wed, 15 Sep 2010 17:39:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FHdFfG044614; Wed, 15 Sep 2010 17:39:15 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FHdFLc044611; Wed, 15 Sep 2010 17:39:15 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009151739.o8FHdFLc044611@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 17:39:15 +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: r212680 - stable/7/sys/geom/part 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, 15 Sep 2010 17:39:15 -0000 Author: marius Date: Wed Sep 15 17:39:15 2010 New Revision: 212680 URL: http://svn.freebsd.org/changeset/base/212680 Log: MFC: r208515 Fix some whitespace nits. Modified: stable/7/sys/geom/part/g_part_vtoc8.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/geom/part/g_part_vtoc8.c ============================================================================== --- stable/7/sys/geom/part/g_part_vtoc8.c Wed Sep 15 17:38:59 2010 (r212679) +++ stable/7/sys/geom/part/g_part_vtoc8.c Wed Sep 15 17:39:15 2010 (r212680) @@ -55,17 +55,17 @@ static int g_part_vtoc8_add(struct g_par struct g_part_parms *); static int g_part_vtoc8_create(struct g_part_table *, struct g_part_parms *); static int g_part_vtoc8_destroy(struct g_part_table *, struct g_part_parms *); -static void g_part_vtoc8_dumpconf(struct g_part_table *, struct g_part_entry *, - struct sbuf *, const char *); +static void g_part_vtoc8_dumpconf(struct g_part_table *, + struct g_part_entry *, struct sbuf *, const char *); static int g_part_vtoc8_dumpto(struct g_part_table *, struct g_part_entry *); -static int g_part_vtoc8_modify(struct g_part_table *, struct g_part_entry *, +static int g_part_vtoc8_modify(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); -static const char *g_part_vtoc8_name(struct g_part_table *, struct g_part_entry *, - char *, size_t); +static const char *g_part_vtoc8_name(struct g_part_table *, + struct g_part_entry *, char *, size_t); static int g_part_vtoc8_probe(struct g_part_table *, struct g_consumer *); static int g_part_vtoc8_read(struct g_part_table *, struct g_consumer *); -static const char *g_part_vtoc8_type(struct g_part_table *, struct g_part_entry *, - char *, size_t); +static const char *g_part_vtoc8_type(struct g_part_table *, + struct g_part_entry *, char *, size_t); static int g_part_vtoc8_write(struct g_part_table *, struct g_consumer *); static kobj_method_t g_part_vtoc8_methods[] = { @@ -260,7 +260,8 @@ g_part_vtoc8_dumpconf(struct g_part_tabl } static int -g_part_vtoc8_dumpto(struct g_part_table *basetable, struct g_part_entry *entry) +g_part_vtoc8_dumpto(struct g_part_table *basetable, + struct g_part_entry *entry) { struct g_part_vtoc8_table *table; uint16_t tag; @@ -456,7 +457,7 @@ g_part_vtoc8_read(struct g_part_table *b } static const char * -g_part_vtoc8_type(struct g_part_table *basetable, struct g_part_entry *entry, +g_part_vtoc8_type(struct g_part_table *basetable, struct g_part_entry *entry, char *buf, size_t bufsz) { struct g_part_vtoc8_table *table; From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 18:09:16 2010 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 62E37106566C; Wed, 15 Sep 2010 18:09:16 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48F7D8FC08; Wed, 15 Sep 2010 18:09:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FI9GDm045553; Wed, 15 Sep 2010 18:09:16 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FI9GL7045546; Wed, 15 Sep 2010 18:09:16 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009151809.o8FI9GL7045546@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 18:09:16 +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: r212683 - in stable/7/sys: sparc64/include sparc64/sparc64 sun4v/include sun4v/sun4v 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, 15 Sep 2010 18:09:16 -0000 Author: marius Date: Wed Sep 15 18:09:15 2010 New Revision: 212683 URL: http://svn.freebsd.org/changeset/base/212683 Log: MFC: r210176 Allocate proper amount of memory for interrupt names on sparc64 and sun4v, same as done on other architectures. This removes garbage from `vmstat -ia` output. Modified: stable/7/sys/sparc64/include/intr_machdep.h stable/7/sys/sparc64/sparc64/exception.S stable/7/sys/sparc64/sparc64/genassym.c stable/7/sys/sun4v/include/intr_machdep.h stable/7/sys/sun4v/sun4v/exception.S Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/include/intr_machdep.h ============================================================================== --- stable/7/sys/sparc64/include/intr_machdep.h Wed Sep 15 17:59:22 2010 (r212682) +++ stable/7/sys/sparc64/include/intr_machdep.h Wed Sep 15 18:09:15 2010 (r212683) @@ -33,7 +33,6 @@ #define PIL_MAX (1 << 4) #define IV_MAX (1 << 11) -#define IV_NAMLEN 1024 #define IR_FREE (PIL_MAX * 2) Modified: stable/7/sys/sparc64/sparc64/exception.S ============================================================================== --- stable/7/sys/sparc64/sparc64/exception.S Wed Sep 15 17:59:22 2010 (r212682) +++ stable/7/sys/sparc64/sparc64/exception.S Wed Sep 15 18:09:15 2010 (r212683) @@ -365,7 +365,7 @@ ENTRY(rsf_fatal) sir END(rsf_fatal) - .comm intrnames, IV_NAMLEN + .comm intrnames, IV_MAX * (MAXCOMLEN + 1) .comm eintrnames, 0 .comm intrcnt, IV_MAX * 8 Modified: stable/7/sys/sparc64/sparc64/genassym.c ============================================================================== --- stable/7/sys/sparc64/sparc64/genassym.c Wed Sep 15 17:59:22 2010 (r212682) +++ stable/7/sys/sparc64/sparc64/genassym.c Wed Sep 15 18:09:15 2010 (r212683) @@ -160,6 +160,7 @@ ASSYM(HASH_ENTRY_SHIFT, HASH_ENTRY_SHIFT ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); +ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); Modified: stable/7/sys/sun4v/include/intr_machdep.h ============================================================================== --- stable/7/sys/sun4v/include/intr_machdep.h Wed Sep 15 17:59:22 2010 (r212682) +++ stable/7/sys/sun4v/include/intr_machdep.h Wed Sep 15 18:09:15 2010 (r212683) @@ -33,7 +33,6 @@ #define PIL_MAX (1 << 4) #define IV_MAX (1 << 11) -#define IV_NAMLEN 1024 #define IR_FREE (PIL_MAX * 2) Modified: stable/7/sys/sun4v/sun4v/exception.S ============================================================================== --- stable/7/sys/sun4v/sun4v/exception.S Wed Sep 15 17:59:22 2010 (r212682) +++ stable/7/sys/sun4v/sun4v/exception.S Wed Sep 15 18:09:15 2010 (r212683) @@ -1948,7 +1948,7 @@ END(fork_trampoline) - .comm intrnames, IV_NAMLEN + .comm intrnames, IV_MAX * (MAXCOMLEN + 1) .comm eintrnames, 0 .comm intrcnt, IV_MAX * 8 From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 18:51:15 2010 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 5AA261065672; Wed, 15 Sep 2010 18:51:15 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48DD38FC15; Wed, 15 Sep 2010 18:51:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FIpFwK046709; Wed, 15 Sep 2010 18:51:15 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FIpFEa046702; Wed, 15 Sep 2010 18:51:15 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009151851.o8FIpFEa046702@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 18:51:15 +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: r212686 - in stable/7/sys/sparc64: include sparc64 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, 15 Sep 2010 18:51:15 -0000 Author: marius Date: Wed Sep 15 18:51:15 2010 New Revision: 212686 URL: http://svn.freebsd.org/changeset/base/212686 Log: MFC: r211049, r211568 For CPUs which ignore TD_CV and support hardware unaliasing don't bother doing page coloring. This results in a small but measurable performance improvement in buildworld times. Modified: stable/7/sys/sparc64/include/cache.h stable/7/sys/sparc64/sparc64/cache.c stable/7/sys/sparc64/sparc64/mem.c stable/7/sys/sparc64/sparc64/pmap.c stable/7/sys/sparc64/sparc64/uio_machdep.c stable/7/sys/sparc64/sparc64/vm_machdep.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/include/cache.h ============================================================================== --- stable/7/sys/sparc64/include/cache.h Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/include/cache.h Wed Sep 15 18:51:15 2010 (r212686) @@ -49,7 +49,7 @@ #define DCACHE_COLORS (1 << DCACHE_COLOR_BITS) #define DCACHE_COLOR_MASK (DCACHE_COLORS - 1) #define DCACHE_COLOR(va) (((va) >> PAGE_SHIFT) & DCACHE_COLOR_MASK) -#define DCACHE_OTHER_COLOR(color) \ +#define DCACHE_OTHER_COLOR(color) \ ((color) ^ DCACHE_COLOR_BITS) #define DC_TAG_SHIFT 2 @@ -89,6 +89,8 @@ struct cacheinfo { #ifdef _KERNEL +extern u_int dcache_color_ignore; + struct pcpu; typedef void cache_enable_t(u_int cpu_impl); Modified: stable/7/sys/sparc64/sparc64/cache.c ============================================================================== --- stable/7/sys/sparc64/sparc64/cache.c Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/sparc64/cache.c Wed Sep 15 18:51:15 2010 (r212686) @@ -88,6 +88,8 @@ cache_flush_t *cache_flush; dcache_page_inval_t *dcache_page_inval; icache_page_inval_t *icache_page_inval; +u_int dcache_color_ignore; + #define OF_GET(h, n, v) OF_getprop((h), (n), &(v), sizeof(v)) static u_int cache_new_prop(u_int cpu_impl); @@ -114,6 +116,13 @@ cache_init(struct pcpu *pcpu) u_long set; u_int use_new_prop; + /* + * For CPUs which ignore TD_CV and support hardware unaliasing don't + * bother doing page coloring. This is equal across all CPUs. + */ + if (pcpu->pc_cpuid == 0 && pcpu->pc_impl == CPU_IMPL_SPARC64V) + dcache_color_ignore = 1; + use_new_prop = cache_new_prop(pcpu->pc_impl); if (OF_GET(pcpu->pc_node, !use_new_prop ? "icache-size" : "l1-icache-size", pcpu->pc_cache.ic_size) == -1 || @@ -145,9 +154,8 @@ cache_init(struct pcpu *pcpu) * For CPUs which don't support unaliasing in hardware ensure that * the data cache doesn't have too many virtual colors. */ - if (pcpu->pc_impl != CPU_IMPL_SPARC64V && - ((pcpu->pc_cache.dc_size / pcpu->pc_cache.dc_assoc) / - PAGE_SIZE) != DCACHE_COLORS) + if (dcache_color_ignore == 0 && ((pcpu->pc_cache.dc_size / + pcpu->pc_cache.dc_assoc) / PAGE_SIZE) != DCACHE_COLORS) panic("cache_init: too many D$ colors"); set = pcpu->pc_cache.ec_size / pcpu->pc_cache.ec_assoc; if ((set & ~(1UL << (ffs(set) - 1))) != 0) Modified: stable/7/sys/sparc64/sparc64/mem.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mem.c Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/sparc64/mem.c Wed Sep 15 18:51:15 2010 (r212686) @@ -95,8 +95,10 @@ memrw(struct cdev *dev, struct uio *uio, vm_page_t m; int error; int i; + uint32_t colors; cnt = 0; + colors = 1; error = 0; ova = 0; @@ -134,20 +136,20 @@ memrw(struct cdev *dev, struct uio *uio, } if (m != NULL) { + if (ova == 0) { #ifndef SUN4V - if (ova == 0) + if (dcache_color_ignore == 0) + colors = DCACHE_COLORS; +#endif ova = kmem_alloc_wait(kernel_map, - PAGE_SIZE * DCACHE_COLORS); - if (m->md.color != -1) + PAGE_SIZE * colors); + } +#ifndef SUN4V + if (colors != 1 && m->md.color != -1) va = ova + m->md.color * PAGE_SIZE; else - va = ova; -#else - if (ova == 0) - ova = kmem_alloc_wait(kernel_map, - PAGE_SIZE); - va = ova; #endif + va = ova; pmap_qenter(va, &m, 1); error = uiomove((void *)(va + off), cnt, uio); @@ -158,8 +160,7 @@ memrw(struct cdev *dev, struct uio *uio, uio); } break; - } - else if (minor(dev) == CDEV_MINOR_KMEM) { + } else if (minor(dev) == CDEV_MINOR_KMEM) { va = trunc_page(uio->uio_offset); eva = round_page(uio->uio_offset + iov->iov_len); @@ -184,15 +185,12 @@ memrw(struct cdev *dev, struct uio *uio, /* else panic! */ } if (ova != 0) -#ifndef SUN4V - kmem_free_wakeup(kernel_map, ova, PAGE_SIZE * DCACHE_COLORS); -#else - kmem_free_wakeup(kernel_map, ova, PAGE_SIZE); -#endif + kmem_free_wakeup(kernel_map, ova, PAGE_SIZE * colors); return (error); } void dev_mem_md_init(void) { + } Modified: stable/7/sys/sparc64/sparc64/pmap.c ============================================================================== --- stable/7/sys/sparc64/sparc64/pmap.c Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/sparc64/pmap.c Wed Sep 15 18:51:15 2010 (r212686) @@ -154,7 +154,7 @@ struct pmap kernel_pmap_store; /* * Allocate physical memory for use in pmap_bootstrap. */ -static vm_paddr_t pmap_bootstrap_alloc(vm_size_t size); +static vm_paddr_t pmap_bootstrap_alloc(vm_size_t size, uint32_t colors); /* * Map the given physical page at the specified virtual address in the @@ -308,6 +308,9 @@ pmap_bootstrap(u_int cpu_impl) int i; int j; int sz; + uint32_t colors; + + colors = dcache_color_ignore != 0 ? 1 : DCACHE_COLORS; /* * Find out what physical memory is available from the PROM and @@ -379,7 +382,7 @@ pmap_bootstrap(u_int cpu_impl) /* * Allocate the kernel TSB and lock it in the TLB. */ - pa = pmap_bootstrap_alloc(tsb_kernel_size); + pa = pmap_bootstrap_alloc(tsb_kernel_size, colors); if (pa & PAGE_MASK_4M) panic("pmap_bootstrap: tsb unaligned\n"); tsb_kernel_phys = pa; @@ -390,7 +393,7 @@ pmap_bootstrap(u_int cpu_impl) /* * Allocate and map the message buffer. */ - pa = pmap_bootstrap_alloc(MSGBUF_SIZE); + pa = pmap_bootstrap_alloc(MSGBUF_SIZE, colors); msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(pa); /* @@ -452,26 +455,26 @@ pmap_bootstrap(u_int cpu_impl) * Allocate kva space for temporary mappings. */ pmap_idle_map = virtual_avail; - virtual_avail += PAGE_SIZE * DCACHE_COLORS; + virtual_avail += PAGE_SIZE * colors; pmap_temp_map_1 = virtual_avail; - virtual_avail += PAGE_SIZE * DCACHE_COLORS; + virtual_avail += PAGE_SIZE * colors; pmap_temp_map_2 = virtual_avail; - virtual_avail += PAGE_SIZE * DCACHE_COLORS; + virtual_avail += PAGE_SIZE * colors; /* * Allocate a kernel stack with guard page for thread0 and map it * into the kernel TSB. We must ensure that the virtual address is - * coloured properly, since we're allocating from phys_avail so the - * memory won't have an associated vm_page_t. + * colored properly for corresponding CPUs, since we're allocating + * from phys_avail so the memory won't have an associated vm_page_t. */ - pa = pmap_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE); + pa = pmap_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE, colors); kstack0_phys = pa; - virtual_avail += roundup(KSTACK_GUARD_PAGES, DCACHE_COLORS) * - PAGE_SIZE; + virtual_avail += roundup(KSTACK_GUARD_PAGES, colors) * PAGE_SIZE; kstack0 = virtual_avail; - virtual_avail += roundup(KSTACK_PAGES, DCACHE_COLORS) * PAGE_SIZE; - KASSERT(DCACHE_COLOR(kstack0) == DCACHE_COLOR(kstack0_phys), - ("pmap_bootstrap: kstack0 miscoloured")); + virtual_avail += roundup(KSTACK_PAGES, colors) * PAGE_SIZE; + if (dcache_color_ignore == 0) + KASSERT(DCACHE_COLOR(kstack0) == DCACHE_COLOR(kstack0_phys), + ("pmap_bootstrap: kstack0 miscolored")); for (i = 0; i < KSTACK_PAGES; i++) { pa = kstack0_phys + i * PAGE_SIZE; va = kstack0 + i * PAGE_SIZE; @@ -603,12 +606,12 @@ pmap_map_tsb(void) * calculated. */ static vm_paddr_t -pmap_bootstrap_alloc(vm_size_t size) +pmap_bootstrap_alloc(vm_size_t size, uint32_t colors) { vm_paddr_t pa; int i; - size = roundup(size, PAGE_SIZE * DCACHE_COLORS); + size = roundup(size, PAGE_SIZE * colors); for (i = 0; phys_avail[i + 1] != 0; i += 2) { if (phys_avail[i + 1] - phys_avail[i] < size) continue; @@ -745,6 +748,9 @@ pmap_cache_enter(vm_page_t m, vm_offset_ ("pmap_cache_enter: fake page")); PMAP_STATS_INC(pmap_ncache_enter); + if (dcache_color_ignore != 0) + return (1); + /* * Find the color for this virtual address and note the added mapping. */ @@ -817,10 +823,14 @@ pmap_cache_remove(vm_page_t m, vm_offset m->md.colors[DCACHE_COLOR(va)]); KASSERT((m->flags & PG_FICTITIOUS) == 0, ("pmap_cache_remove: fake page")); + PMAP_STATS_INC(pmap_ncache_remove); + + if (dcache_color_ignore != 0) + return; + KASSERT(m->md.colors[DCACHE_COLOR(va)] > 0, ("pmap_cache_remove: no mappings %d <= 0", m->md.colors[DCACHE_COLOR(va)])); - PMAP_STATS_INC(pmap_ncache_remove); /* * Find the color for this virtual address and note the removal of @@ -890,7 +900,7 @@ pmap_kenter(vm_offset_t va, vm_page_t m) va, VM_PAGE_TO_PHYS(m), tp, tp->tte_data); if (DCACHE_COLOR(VM_PAGE_TO_PHYS(m)) != DCACHE_COLOR(va)) { CTR6(KTR_CT2, - "pmap_kenter: off colour va=%#lx pa=%#lx o=%p oc=%#lx ot=%d pi=%#lx", + "pmap_kenter: off color va=%#lx pa=%#lx o=%p oc=%#lx ot=%d pi=%#lx", va, VM_PAGE_TO_PHYS(m), m->object, m->object ? m->object->pg_color : -1, m->object ? m->object->type : -1, @@ -1604,13 +1614,13 @@ pmap_zero_page(vm_page_t m) ("pmap_zero_page: fake page")); PMAP_STATS_INC(pmap_nzero_page); pa = VM_PAGE_TO_PHYS(m); - if (m->md.color == -1) { - PMAP_STATS_INC(pmap_nzero_page_nc); - aszero(ASI_PHYS_USE_EC, pa, PAGE_SIZE); - } else if (m->md.color == DCACHE_COLOR(pa)) { + if (dcache_color_ignore != 0 || m->md.color == DCACHE_COLOR(pa)) { PMAP_STATS_INC(pmap_nzero_page_c); va = TLB_PHYS_TO_DIRECT(pa); cpu_block_zero((void *)va, PAGE_SIZE); + } else if (m->md.color == -1) { + PMAP_STATS_INC(pmap_nzero_page_nc); + aszero(ASI_PHYS_USE_EC, pa, PAGE_SIZE); } else { PMAP_STATS_INC(pmap_nzero_page_oc); PMAP_LOCK(kernel_pmap); @@ -1636,13 +1646,13 @@ pmap_zero_page_area(vm_page_t m, int off KASSERT(off + size <= PAGE_SIZE, ("pmap_zero_page_area: bad off/size")); PMAP_STATS_INC(pmap_nzero_page_area); pa = VM_PAGE_TO_PHYS(m); - if (m->md.color == -1) { - PMAP_STATS_INC(pmap_nzero_page_area_nc); - aszero(ASI_PHYS_USE_EC, pa + off, size); - } else if (m->md.color == DCACHE_COLOR(pa)) { + if (dcache_color_ignore != 0 || m->md.color == DCACHE_COLOR(pa)) { PMAP_STATS_INC(pmap_nzero_page_area_c); va = TLB_PHYS_TO_DIRECT(pa); bzero((void *)(va + off), size); + } else if (m->md.color == -1) { + PMAP_STATS_INC(pmap_nzero_page_area_nc); + aszero(ASI_PHYS_USE_EC, pa + off, size); } else { PMAP_STATS_INC(pmap_nzero_page_area_oc); PMAP_LOCK(kernel_pmap); @@ -1667,13 +1677,13 @@ pmap_zero_page_idle(vm_page_t m) ("pmap_zero_page_idle: fake page")); PMAP_STATS_INC(pmap_nzero_page_idle); pa = VM_PAGE_TO_PHYS(m); - if (m->md.color == -1) { - PMAP_STATS_INC(pmap_nzero_page_idle_nc); - aszero(ASI_PHYS_USE_EC, pa, PAGE_SIZE); - } else if (m->md.color == DCACHE_COLOR(pa)) { + if (dcache_color_ignore != 0 || m->md.color == DCACHE_COLOR(pa)) { PMAP_STATS_INC(pmap_nzero_page_idle_c); va = TLB_PHYS_TO_DIRECT(pa); cpu_block_zero((void *)va, PAGE_SIZE); + } else if (m->md.color == -1) { + PMAP_STATS_INC(pmap_nzero_page_idle_nc); + aszero(ASI_PHYS_USE_EC, pa, PAGE_SIZE); } else { PMAP_STATS_INC(pmap_nzero_page_idle_oc); va = pmap_idle_map + (m->md.color * PAGE_SIZE); @@ -1701,15 +1711,16 @@ pmap_copy_page(vm_page_t msrc, vm_page_t PMAP_STATS_INC(pmap_ncopy_page); pdst = VM_PAGE_TO_PHYS(mdst); psrc = VM_PAGE_TO_PHYS(msrc); - if (msrc->md.color == -1 && mdst->md.color == -1) { - PMAP_STATS_INC(pmap_ncopy_page_nc); - ascopy(ASI_PHYS_USE_EC, psrc, pdst, PAGE_SIZE); - } else if (msrc->md.color == DCACHE_COLOR(psrc) && - mdst->md.color == DCACHE_COLOR(pdst)) { + if (dcache_color_ignore != 0 || + (msrc->md.color == DCACHE_COLOR(psrc) && + mdst->md.color == DCACHE_COLOR(pdst))) { PMAP_STATS_INC(pmap_ncopy_page_c); vdst = TLB_PHYS_TO_DIRECT(pdst); vsrc = TLB_PHYS_TO_DIRECT(psrc); cpu_block_copy((void *)vsrc, (void *)vdst, PAGE_SIZE); + } else if (msrc->md.color == -1 && mdst->md.color == -1) { + PMAP_STATS_INC(pmap_ncopy_page_nc); + ascopy(ASI_PHYS_USE_EC, psrc, pdst, PAGE_SIZE); } else if (msrc->md.color == -1) { if (mdst->md.color == DCACHE_COLOR(pdst)) { PMAP_STATS_INC(pmap_ncopy_page_dc); Modified: stable/7/sys/sparc64/sparc64/uio_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/uio_machdep.c Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/sparc64/uio_machdep.c Wed Sep 15 18:51:15 2010 (r212686) @@ -51,12 +51,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include /* * Implement uiomove(9) from physical memory using a combination * of the direct mapping and sf_bufs to reduce the creation and - * destruction of ephemeral mappings. + * destruction of ephemeral mappings. */ int uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio) @@ -92,7 +93,8 @@ uiomove_fromphys(vm_page_t ma[], vm_offs cnt = ulmin(cnt, PAGE_SIZE - page_offset); m = ma[offset >> PAGE_SHIFT]; pa = VM_PAGE_TO_PHYS(m); - if (m->md.color != DCACHE_COLOR(pa)) { + if (dcache_color_ignore == 0 && + m->md.color != DCACHE_COLOR(pa)) { sf = sf_buf_alloc(m, 0); cp = (char *)sf_buf_kva(sf) + page_offset; } else { Modified: stable/7/sys/sparc64/sparc64/vm_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/vm_machdep.c Wed Sep 15 18:51:14 2010 (r212685) +++ stable/7/sys/sparc64/sparc64/vm_machdep.c Wed Sep 15 18:51:15 2010 (r212686) @@ -191,7 +191,7 @@ cpu_set_upcall(struct thread *td, struct void cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, - stack_t *stack) + stack_t *stack) { struct trapframe *tf; uint64_t sp; @@ -215,7 +215,7 @@ cpu_set_user_tls(struct thread *td, void if (td == curthread) flushw(); - td->td_frame->tf_global[7] = (uint64_t) tls_base; + td->td_frame->tf_global[7] = (uint64_t)tls_base; return (0); } @@ -495,7 +495,7 @@ uma_small_alloc(uma_zone_t zone, int byt } pa = VM_PAGE_TO_PHYS(m); - if (m->md.color != DCACHE_COLOR(pa)) { + if (dcache_color_ignore == 0 && m->md.color != DCACHE_COLOR(pa)) { KASSERT(m->md.colors[0] == 0 && m->md.colors[1] == 0, ("uma_small_alloc: free page still has mappings!")); PMAP_STATS_INC(uma_nsmall_alloc_oc); From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 19:28:06 2010 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 A76CA10656A3; Wed, 15 Sep 2010 19:28:06 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 954E58FC25; Wed, 15 Sep 2010 19:28:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FJS6HC047915; Wed, 15 Sep 2010 19:28:06 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FJS6pi047912; Wed, 15 Sep 2010 19:28:06 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009151928.o8FJS6pi047912@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 19:28: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: r212690 - in stable/7/sys/sparc64: include sparc64 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, 15 Sep 2010 19:28:06 -0000 Author: marius Date: Wed Sep 15 19:28:06 2010 New Revision: 212690 URL: http://svn.freebsd.org/changeset/base/212690 Log: MFC: r211050 (partial) - Introduce a cpu_ipi_single() function pointer in order to send IPIs to single CPUs more efficiently with Cheetah(-class) and Jalapeno CPUs. - Factor out the Jalapeno support from the Cheetah IPI send functions in order to be able to more easily and efficiently implement support for more than 32 target CPUs as well as a workaround for Cheetah+ erratum 25 for the latter. Modified: stable/7/sys/sparc64/include/smp.h stable/7/sys/sparc64/sparc64/mp_machdep.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/include/smp.h ============================================================================== --- stable/7/sys/sparc64/include/smp.h Wed Sep 15 19:27:30 2010 (r212689) +++ stable/7/sys/sparc64/include/smp.h Wed Sep 15 19:28:06 2010 (r212690) @@ -95,6 +95,8 @@ void cpu_mp_shutdown(void); typedef void cpu_ipi_selected_t(u_int, u_long, u_long, u_long); extern cpu_ipi_selected_t *cpu_ipi_selected; +typedef void cpu_ipi_single_t(u_int, u_long, u_long, u_long); +extern cpu_ipi_single_t *cpu_ipi_single; void mp_init(u_int cpu_impl); @@ -229,7 +231,8 @@ ipi_tlb_range_demap(struct pmap *pm, vm_ ita->ita_pmap = pm; ita->ita_start = start; ita->ita_end = end; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_range_demap, (u_long)ita); + cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_range_demap, + (u_long)ita); return (&ita->ita_mask); } Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Wed Sep 15 19:27:30 2010 (r212689) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Wed Sep 15 19:28:06 2010 (r212690) @@ -29,7 +29,7 @@ */ /*- * Copyright (c) 2002 Jake Burkholder. - * Copyright (c) 2007 Marius Strobl + * Copyright (c) 2007 - 2010 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,6 +113,7 @@ struct pcb stoppcbs[MAXCPU]; struct mtx ipi_mtx; cpu_ipi_selected_t *cpu_ipi_selected; +cpu_ipi_single_t *cpu_ipi_single; static vm_offset_t mp_tramp; static u_int cpuid_to_mid[MAXCPU]; @@ -124,11 +125,14 @@ static void ap_start(phandle_t node, u_i static void cpu_mp_unleash(void *v); static void foreach_ap(phandle_t node, void (*func)(phandle_t node, u_int mid, u_int cpu_impl)); -static void spitfire_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2); static void sun4u_startcpu(phandle_t cpu, void *func, u_long arg); static cpu_ipi_selected_t cheetah_ipi_selected; +static cpu_ipi_single_t cheetah_ipi_single; +static cpu_ipi_selected_t jalapeno_ipi_selected; +static cpu_ipi_single_t jalapeno_ipi_single; static cpu_ipi_selected_t spitfire_ipi_selected; +static cpu_ipi_single_t spitfire_ipi_single; SYSINIT(cpu_mp_unleash, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL); @@ -162,13 +166,18 @@ mp_init(u_int cpu_impl) * cpu_mp_start() wasn't so initialize these here. */ if (cpu_impl == CPU_IMPL_ULTRASPARCIIIi || - cpu_impl == CPU_IMPL_ULTRASPARCIIIip) + cpu_impl == CPU_IMPL_ULTRASPARCIIIip) { isjbus = 1; - if (cpu_impl == CPU_IMPL_SPARC64V || - cpu_impl >= CPU_IMPL_ULTRASPARCIII) + cpu_ipi_selected = jalapeno_ipi_selected; + cpu_ipi_single = jalapeno_ipi_single; + } else if (cpu_impl == CPU_IMPL_SPARC64V || + cpu_impl >= CPU_IMPL_ULTRASPARCIII) { cpu_ipi_selected = cheetah_ipi_selected; - else + cpu_ipi_single = cheetah_ipi_single; + } else { cpu_ipi_selected = spitfire_ipi_selected; + cpu_ipi_single = spitfire_ipi_single; + } } static void @@ -179,7 +188,7 @@ foreach_ap(phandle_t node, void (*func)( phandle_t child; u_int cpuid; uint32_t cpu_impl; - + /* There's no need to traverse the whole OFW tree twice. */ if (mp_maxid > 0 && mp_ncpus >= mp_maxid + 1) return; @@ -199,7 +208,7 @@ foreach_ap(phandle_t node, void (*func)( panic("%s: couldn't determine CPU " "implementation", __func__); if (OF_getprop(node, cpu_cpuid_prop(cpu_impl), &cpuid, - sizeof(cpuid)) <= 0) + sizeof(cpuid)) <= 0) panic("%s: couldn't determine CPU module ID", __func__); if (cpuid == PCPU_GET(mid)) @@ -511,24 +520,25 @@ spitfire_ipi_selected(u_int cpus, u_long { u_int cpu; - KASSERT((cpus & (1 << curcpu)) == 0, - ("%s: CPU can't IPI itself", __func__)); while (cpus) { cpu = ffs(cpus) - 1; cpus &= ~(1 << cpu); - spitfire_ipi_send(cpuid_to_mid[cpu], d0, d1, d2); + spitfire_ipi_single(cpu, d0, d1, d2); } } static void -spitfire_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2) +spitfire_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2) { register_t s; u_long ids; + u_int mid; int i; + KASSERT(cpu != curcpu, ("%s: CPU can't IPI itself", __func__)); KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & IDR_BUSY) == 0, ("%s: outstanding dispatch", __func__)); + mid = cpuid_to_mid[cpu]; for (i = 0; i < IPI_RETRIES; i++) { s = intr_disable(); stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); @@ -569,6 +579,49 @@ spitfire_ipi_send(u_int mid, u_long d0, } static void +cheetah_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2) +{ + register_t s; + u_long ids; + u_int mid; + int i; + + KASSERT(cpu != curcpu, ("%s: CPU can't IPI itself", __func__)); + KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & + IDR_CHEETAH_ALL_BUSY) == 0, + ("%s: outstanding dispatch", __func__)); + mid = cpuid_to_mid[cpu]; + for (i = 0; i < IPI_RETRIES; i++) { + s = intr_disable(); + stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); + stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1); + stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); + membar(Sync); + stxa(AA_INTR_SEND | (mid << IDC_ITID_SHIFT), + ASI_SDB_INTR_W, 0); + membar(Sync); + while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) & + IDR_BUSY) != 0) + ; + intr_restore(s); + if ((ids & (IDR_BUSY | IDR_NACK)) == 0) + return; + /* + * Leave interrupts enabled for a bit before retrying + * in order to avoid deadlocks if the other CPU is also + * trying to send an IPI. + */ + DELAY(2); + } + if (kdb_active != 0 || panicstr != NULL) + printf("%s: couldn't send IPI to module 0x%u\n", + __func__, mid); + else + panic("%s: couldn't send IPI to module 0x%u", + __func__, mid); +} + +static void cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) { register_t s; @@ -594,9 +647,8 @@ cheetah_ipi_selected(u_int cpus, u_long bnp = 0; for (cpu = 0; cpu < mp_ncpus; cpu++) { if ((cpus & (1 << cpu)) != 0) { - stxa(AA_INTR_SEND | - (cpuid_to_mid[cpu] << IDC_ITID_SHIFT) | - (isjbus ? 0 : bnp << IDC_BN_SHIFT), + stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << + IDC_ITID_SHIFT) | bnp << IDC_BN_SHIFT, ASI_SDB_INTR_W, 0); membar(Sync); bnp++; @@ -606,14 +658,13 @@ cheetah_ipi_selected(u_int cpus, u_long IDR_CHEETAH_ALL_BUSY) != 0) ; intr_restore(s); - if ((ids & (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0) + if ((ids & + (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0) return; bnp = 0; for (cpu = 0; cpu < mp_ncpus; cpu++) { if ((cpus & (1 << cpu)) != 0) { - if ((ids & (IDR_NACK << (isjbus ? - (2 * cpuid_to_mid[cpu]) : - (2 * bnp)))) == 0) + if ((ids & (IDR_NACK << (2 * bnp))) == 0) cpus &= ~(1 << cpu); bnp++; } @@ -639,3 +690,104 @@ cheetah_ipi_selected(u_int cpus, u_long panic("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)", __func__, cpus, ids); } + +static void +jalapeno_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2) +{ + register_t s; + u_long ids; + u_int busy, busynack, mid; + int i; + + KASSERT(cpu != curcpu, ("%s: CPU can't IPI itself", __func__)); + KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & + IDR_CHEETAH_ALL_BUSY) == 0, + ("%s: outstanding dispatch", __func__)); + mid = cpuid_to_mid[cpu]; + busy = IDR_BUSY << (2 * mid); + busynack = (IDR_BUSY | IDR_NACK) << (2 * mid); + for (i = 0; i < IPI_RETRIES; i++) { + s = intr_disable(); + stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); + stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1); + stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); + membar(Sync); + stxa(AA_INTR_SEND | (mid << IDC_ITID_SHIFT), + ASI_SDB_INTR_W, 0); + membar(Sync); + while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) & + busy) != 0) + ; + intr_restore(s); + if ((ids & busynack) == 0) + return; + /* + * Leave interrupts enabled for a bit before retrying + * in order to avoid deadlocks if the other CPU is also + * trying to send an IPI. + */ + DELAY(2); + } + if (kdb_active != 0 || panicstr != NULL) + printf("%s: couldn't send IPI to module 0x%u\n", + __func__, mid); + else + panic("%s: couldn't send IPI to module 0x%u", + __func__, mid); +} + +static void +jalapeno_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) +{ + register_t s; + u_long ids; + u_int cpu; + int i; + + KASSERT((cpus & (1 << curcpu)) == 0, + ("%s: CPU can't IPI itself", __func__)); + KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & + IDR_CHEETAH_ALL_BUSY) == 0, + ("%s: outstanding dispatch", __func__)); + if (cpus == 0) + return; + ids = 0; + for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) { + s = intr_disable(); + stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); + stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1); + stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); + membar(Sync); + for (cpu = 0; cpu < mp_ncpus; cpu++) { + if ((cpus & (1 << cpu)) != 0) { + stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << + IDC_ITID_SHIFT), ASI_SDB_INTR_W, 0); + membar(Sync); + } + } + while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) & + IDR_CHEETAH_ALL_BUSY) != 0) + ; + intr_restore(s); + if ((ids & + (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0) + return; + for (cpu = 0; cpu < mp_ncpus; cpu++) + if ((cpus & (1 << cpu)) != 0) + if ((ids & (IDR_NACK << + (2 * cpuid_to_mid[cpu]))) == 0) + cpus &= ~(1 << cpu); + /* + * Leave interrupts enabled for a bit before retrying + * in order to avoid deadlocks if the other CPUs are + * also trying to send IPIs. + */ + DELAY(2 * mp_ncpus); + } + if (kdb_active != 0 || panicstr != NULL) + printf("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)\n", + __func__, cpus, ids); + else + panic("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)", + __func__, cpus, ids); +} From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 20:17:22 2010 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 5E38D1065755; Wed, 15 Sep 2010 20:17:20 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A5C3A8FC15; Wed, 15 Sep 2010 20:17:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FKHKNY049434; Wed, 15 Sep 2010 20:17:20 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FKHKqn049427; Wed, 15 Sep 2010 20:17:20 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009152017.o8FKHKqn049427@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 20:17: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: r212696 - in stable/7/sys/sparc64: include sparc64 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, 15 Sep 2010 20:17:22 -0000 Author: marius Date: Wed Sep 15 20:17:20 2010 New Revision: 212696 URL: http://svn.freebsd.org/changeset/base/212696 Log: MFC: r210601 (partial), r211071, r211073 - As it is not possible for sched_bind(9) to context switch with td_critnest > 1 when not already running on the desired CPU read the TICK counter of the BSP via a direct cross trap request in that case instead. - Provide a STICK based timecounter. Modified: stable/7/sys/sparc64/include/smp.h stable/7/sys/sparc64/sparc64/genassym.c stable/7/sys/sparc64/sparc64/mp_exception.S stable/7/sys/sparc64/sparc64/mp_machdep.c stable/7/sys/sparc64/sparc64/tick.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/include/smp.h ============================================================================== --- stable/7/sys/sparc64/include/smp.h Wed Sep 15 20:17:18 2010 (r212695) +++ stable/7/sys/sparc64/include/smp.h Wed Sep 15 20:17:20 2010 (r212696) @@ -78,6 +78,11 @@ struct ipi_cache_args { vm_paddr_t ica_pa; }; +struct ipi_rd_args { + u_int ira_mask; + register_t *ira_val; +}; + struct ipi_tlb_args { u_int ita_mask; struct pmap *ita_pmap; @@ -102,6 +107,7 @@ void mp_init(u_int cpu_impl); extern struct mtx ipi_mtx; extern struct ipi_cache_args ipi_cache_args; +extern struct ipi_rd_args ipi_rd_args; extern struct ipi_tlb_args ipi_tlb_args; extern char *mp_tramp_code; @@ -116,6 +122,10 @@ extern char tl_ipi_spitfire_dcache_page_ extern char tl_ipi_spitfire_icache_page_inval[]; extern char tl_ipi_level[]; + +extern char tl_ipi_stick_rd[]; +extern char tl_ipi_tick_rd[]; + extern char tl_ipi_tlb_context_demap[]; extern char tl_ipi_tlb_page_demap[]; extern char tl_ipi_tlb_range_demap[]; @@ -169,6 +179,22 @@ ipi_icache_page_inval(void *func, vm_pad } static __inline void * +ipi_rd(u_int cpu, void *func, u_long *val) +{ + struct ipi_rd_args *ira; + + if (smp_cpus == 1) + return (NULL); + sched_pin(); + ira = &ipi_rd_args; + mtx_lock_spin(&ipi_mtx); + ira->ira_mask = 1 << cpu | PCPU_GET(cpumask); + ira->ira_val = val; + cpu_ipi_single(cpu, 0, (u_long)func, (u_long)ira); + return (&ira->ira_mask); +} + +static __inline void * ipi_tlb_context_demap(struct pmap *pm) { struct ipi_tlb_args *ita; @@ -273,6 +299,13 @@ ipi_icache_page_inval(void *func __unuse } static __inline void * +ipi_rd(u_int cpu __unused, void *func __unused, u_long *val __unused) +{ + + return (NULL); +} + +static __inline void * ipi_tlb_context_demap(struct pmap *pm __unused) { Modified: stable/7/sys/sparc64/sparc64/genassym.c ============================================================================== --- stable/7/sys/sparc64/sparc64/genassym.c Wed Sep 15 20:17:18 2010 (r212695) +++ stable/7/sys/sparc64/sparc64/genassym.c Wed Sep 15 20:17:20 2010 (r212696) @@ -105,10 +105,6 @@ ASSYM(IC_SIZE, offsetof(struct cacheinfo ASSYM(IC_LINESIZE, offsetof(struct cacheinfo, ic_linesize)); #endif -#ifdef SMP -ASSYM(ICA_PA, offsetof(struct ipi_cache_args, ica_pa)); -#endif - ASSYM(KTR_SIZEOF, sizeof(struct ktr_entry)); ASSYM(KTR_LINE, offsetof(struct ktr_entry, ktr_line)); ASSYM(KTR_FILE, offsetof(struct ktr_entry, ktr_file)); @@ -215,7 +211,12 @@ ASSYM(IR_ARG, offsetof(struct intr_reque ASSYM(IR_PRI, offsetof(struct intr_request, ir_pri)); ASSYM(IR_VEC, offsetof(struct intr_request, ir_vec)); -#ifdef SMP +#if defined(SUN4U) && defined(SMP) +ASSYM(ICA_PA, offsetof(struct ipi_cache_args, ica_pa)); + +ASSYM(IRA_MASK, offsetof(struct ipi_rd_args, ira_mask)); +ASSYM(IRA_VAL, offsetof(struct ipi_rd_args, ira_val)); + ASSYM(ITA_MASK, offsetof(struct ipi_tlb_args, ita_mask)); ASSYM(ITA_PMAP, offsetof(struct ipi_tlb_args, ita_pmap)); ASSYM(ITA_START, offsetof(struct ipi_tlb_args, ita_start)); Modified: stable/7/sys/sparc64/sparc64/mp_exception.S ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_exception.S Wed Sep 15 20:17:18 2010 (r212695) +++ stable/7/sys/sparc64/sparc64/mp_exception.S Wed Sep 15 20:17:20 2010 (r212696) @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); */ ENTRY(tl_ipi_spitfire_dcache_page_inval) #if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_dcache_page_inval: pa=%#lx" + CATR(KTR_SMP, "tl_ipi_spitfire_dcache_page_inval: pa=%#lx" , %g1, %g2, %g3, 7, 8, 9) ldx [%g5 + ICA_PA], %g2 stx %g2, [%g1 + KTR_PARM1] @@ -87,7 +87,7 @@ END(tl_ipi_spitfire_dcache_page_inval) */ ENTRY(tl_ipi_spitfire_icache_page_inval) #if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_icache_page_inval: pa=%#lx" + CATR(KTR_SMP, "tl_ipi_spitfire_icache_page_inval: pa=%#lx" , %g1, %g2, %g3, 7, 8, 9) ldx [%g5 + ICA_PA], %g2 stx %g2, [%g1 + KTR_PARM1] @@ -126,7 +126,7 @@ END(tl_ipi_spitfire_icache_page_inval) */ ENTRY(tl_ipi_cheetah_dcache_page_inval) #if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_dcache_page_inval: pa=%#lx" + CATR(KTR_SMP, "tl_ipi_cheetah_dcache_page_inval: pa=%#lx" , %g1, %g2, %g3, 7, 8, 9) ldx [%g5 + ICA_PA], %g2 stx %g2, [%g1 + KTR_PARM1] @@ -256,7 +256,7 @@ END(tl_ipi_tlb_range_demap) */ ENTRY(tl_ipi_tlb_context_demap) #if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_tlb_page_demap: pm=%p va=%#lx" + CATR(KTR_SMP, "tl_ipi_tlb_context_demap: pm=%p va=%#lx" , %g1, %g2, %g3, 7, 8, 9) ldx [%g5 + ITA_PMAP], %g2 stx %g2, [%g1 + KTR_PARM1] @@ -274,3 +274,27 @@ ENTRY(tl_ipi_tlb_context_demap) IPI_DONE(%g5, %g1, %g2, %g3) retry END(tl_ipi_tlb_context_demap) + +/* + * Read %stick. + */ +ENTRY(tl_ipi_stick_rd) + ldx [%g5 + IRA_VAL], %g1 + rd %asr24, %g2 + stx %g2, [%g1] + + IPI_DONE(%g5, %g1, %g2, %g3) + retry +END(tl_ipi_stick_rd) + +/* + * Read %tick. + */ +ENTRY(tl_ipi_tick_rd) + ldx [%g5 + IRA_VAL], %g1 + rd %tick, %g2 + stx %g2, [%g1] + + IPI_DONE(%g5, %g1, %g2, %g3) + retry +END(tl_ipi_tick_rd) Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Wed Sep 15 20:17:18 2010 (r212695) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Wed Sep 15 20:17:20 2010 (r212696) @@ -107,6 +107,7 @@ static ih_func_t cpu_ipi_stop; */ struct cpu_start_args cpu_start_args = { 0, -1, -1, 0, 0, 0 }; struct ipi_cache_args ipi_cache_args; +struct ipi_rd_args ipi_rd_args; struct ipi_tlb_args ipi_tlb_args; struct pcb stoppcbs[MAXCPU]; Modified: stable/7/sys/sparc64/sparc64/tick.c ============================================================================== --- stable/7/sys/sparc64/sparc64/tick.c Wed Sep 15 20:17:18 2010 (r212695) +++ stable/7/sys/sparc64/sparc64/tick.c Wed Sep 15 20:17:20 2010 (r212696) @@ -42,9 +42,13 @@ __FBSDID("$FreeBSD$"); #include +#include +#include + #include #include #include +#include #include #include @@ -76,10 +80,15 @@ u_int hardclock_use_stick = 0; SYSCTL_INT(_machdep_tick, OID_AUTO, hardclock_use_stick, CTLFLAG_RD, &hardclock_use_stick, 0, "hardclock uses STICK instead of TICK timer"); +static struct timecounter stick_tc; static struct timecounter tick_tc; static u_long tick_increment; static uint64_t tick_cputicks(void); +static timecounter_get_t stick_get_timecount_up; +#ifdef SMP +static timecounter_get_t stick_get_timecount_mp; +#endif static timecounter_get_t tick_get_timecount_up; #ifdef SMP static timecounter_get_t tick_get_timecount_mp; @@ -101,25 +110,31 @@ tick_cputicks(void) void cpu_initclocks(void) { - uint32_t clock; + uint32_t clock, sclock; stathz = hz; + clock = PCPU_GET(clock); + sclock = 0; + if (PCPU_GET(impl) == CPU_IMPL_SPARC64V || + PCPU_GET(impl) >= CPU_IMPL_ULTRASPARCIII) { + if (OF_getprop(OF_parent(PCPU_GET(node)), "stick-frequency", + &sclock, sizeof(sclock)) == -1) { + panic("%s: could not determine STICK frequency", + __func__); + } + } /* * Given that the STICK timers typically are driven at rather low * frequencies they shouldn't be used except when really necessary. */ if (hardclock_use_stick != 0) { - if (OF_getprop(OF_parent(PCPU_GET(node)), "stick-frequency", - &clock, sizeof(clock)) == -1) - panic("%s: could not determine STICK frequency", __func__); intr_setup(PIL_TICK, stick_hardclock, -1, NULL, NULL); /* * We don't provide a CPU ticker as long as the frequency * supplied isn't actually used per-CPU. */ } else { - clock = PCPU_GET(clock); intr_setup(PIL_TICK, PCPU_GET(impl) >= CPU_IMPL_ULTRASPARCI && PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ? tick_hardclock_bbwar : tick_hardclock, -1, NULL, NULL); @@ -136,31 +151,45 @@ cpu_initclocks(void) tick_start(); /* - * Initialize the TICK-based timecounter. This must not happen - * before SI_SUB_INTRINSIC for tick_get_timecount_mp() to work. + * Initialize the (S)TICK-based timecounter(s). + * Note that we (try to) sync the (S)TICK timers of APs with the BSP + * during their startup but not afterwards. The resulting drift can + * cause problems when the time is calculated based on (S)TICK values + * read on different CPUs. Thus we always read the register on the + * BSP (if necessary via an IPI as sched_bind(9) isn't available in + * all circumstances) and use a low quality for the otherwise high + * quality (S)TICK timers in the MP case. */ tick_tc.tc_get_timecount = tick_get_timecount_up; tick_tc.tc_poll_pps = NULL; tick_tc.tc_counter_mask = ~0u; - tick_tc.tc_frequency = PCPU_GET(clock); + tick_tc.tc_frequency = clock; tick_tc.tc_name = "tick"; tick_tc.tc_quality = TICK_QUALITY_UP; tick_tc.tc_priv = NULL; #ifdef SMP - /* - * We (try to) sync the (S)TICK timers of APs with the BSP during - * their startup but not afterwards. The resulting drift can - * cause problems when the time is calculated based on (S)TICK - * values read on different CPUs. Thus we bind to the BSP for - * reading the register and use a low quality for the otherwise - * high quality (S)TICK timers in the MP case. - */ if (cpu_mp_probe()) { tick_tc.tc_get_timecount = tick_get_timecount_mp; tick_tc.tc_quality = TICK_QUALITY_MP; } #endif tc_init(&tick_tc); + if (sclock != 0) { + stick_tc.tc_get_timecount = stick_get_timecount_up; + stick_tc.tc_poll_pps = NULL; + stick_tc.tc_counter_mask = ~0u; + stick_tc.tc_frequency = sclock; + stick_tc.tc_name = "stick"; + stick_tc.tc_quality = TICK_QUALITY_UP; + stick_tc.tc_priv = NULL; +#ifdef SMP + if (cpu_mp_probe()) { + stick_tc.tc_get_timecount = stick_get_timecount_mp; + stick_tc.tc_quality = TICK_QUALITY_MP; + } +#endif + tc_init(&stick_tc); + } } static inline void @@ -266,6 +295,13 @@ tick_hardclock_common(struct trapframe * } static u_int +stick_get_timecount_up(struct timecounter *tc) +{ + + return ((u_int)rdstick()); +} + +static u_int tick_get_timecount_up(struct timecounter *tc) { @@ -274,22 +310,30 @@ tick_get_timecount_up(struct timecounter #ifdef SMP static u_int -tick_get_timecount_mp(struct timecounter *tc) +stick_get_timecount_mp(struct timecounter *tc) { - struct thread *td; - u_int tick; + u_long stick; - td = curthread; - thread_lock(td); - sched_bind(td, 0); - thread_unlock(td); - - tick = tick_get_timecount_up(tc); - - thread_lock(td); - sched_unbind(td); - thread_unlock(td); + sched_pin(); + if (curcpu == 0) + stick = rdstick(); + else + ipi_wait(ipi_rd(0, tl_ipi_stick_rd, &stick)); + sched_unpin(); + return (stick); +} +static u_int +tick_get_timecount_mp(struct timecounter *tc) +{ + u_long tick; + + sched_pin(); + if (curcpu == 0) + tick = rd(tick); + else + ipi_wait(ipi_rd(0, tl_ipi_tick_rd, &tick)); + sched_unpin(); return (tick); } #endif From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 20:40:33 2010 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 4F97E1065761; Wed, 15 Sep 2010 20:40:30 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E79F88FC18; Wed, 15 Sep 2010 20:40:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FKeTf9050084; Wed, 15 Sep 2010 20:40:29 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FKeT2P050082; Wed, 15 Sep 2010 20:40:29 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009152040.o8FKeT2P050082@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 20:40: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: r212698 - stable/7/cddl/lib/libzpool 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, 15 Sep 2010 20:40:33 -0000 Author: marius Date: Wed Sep 15 20:40:29 2010 New Revision: 212698 URL: http://svn.freebsd.org/changeset/base/212698 Log: MFC: r208459 Use real atomic operations for sparc64. Modified: stable/7/cddl/lib/libzpool/Makefile Directory Properties: stable/7/cddl/lib/libzpool/ (props changed) Modified: stable/7/cddl/lib/libzpool/Makefile ============================================================================== --- stable/7/cddl/lib/libzpool/Makefile Wed Sep 15 20:40:27 2010 (r212697) +++ stable/7/cddl/lib/libzpool/Makefile Wed Sep 15 20:40:29 2010 (r212698) @@ -11,7 +11,7 @@ # LIST_SRCS .PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/os # ATOMIC_SRCS -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" .PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH} ATOMIC_SRCS= opensolaris_atomic.S .else From owner-svn-src-stable-7@FreeBSD.ORG Thu Sep 16 15:18:47 2010 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 247D61065693; Thu, 16 Sep 2010 15:18:47 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 12F638FC12; Thu, 16 Sep 2010 15:18:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8GFIkS4095820; Thu, 16 Sep 2010 15:18:46 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8GFIkSM095818; Thu, 16 Sep 2010 15:18:46 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201009161518.o8GFIkSM095818@svn.freebsd.org> From: Fabien Thomas Date: Thu, 16 Sep 2010 15:18: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: r212741 - stable/7/sys/dev/hwpmc 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, 16 Sep 2010 15:18:47 -0000 Author: fabient Date: Thu Sep 16 15:18:46 2010 New Revision: 212741 URL: http://svn.freebsd.org/changeset/base/212741 Log: MFC r212224: Fix invalid class removal when IAF is not the last class. Keep IAF class with 0 PMC and change the alias in libpmc to IAP. Modified: stable/7/sys/dev/hwpmc/hwpmc_core.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- stable/7/sys/dev/hwpmc/hwpmc_core.c Thu Sep 16 15:15:34 2010 (r212740) +++ stable/7/sys/dev/hwpmc/hwpmc_core.c Thu Sep 16 15:18:46 2010 (r212741) @@ -2234,21 +2234,8 @@ pmc_core_initialize(struct pmc_mdep *md, core_iaf_npmc = cpuid[CORE_CPUID_EDX] & 0x1F; core_iaf_width = (cpuid[CORE_CPUID_EDX] >> 5) & 0xFF; - if (core_iaf_npmc > 0) { - iaf_initialize(md, maxcpu, core_iaf_npmc, - core_iaf_width); - core_pmcmask |= ((1ULL << core_iaf_npmc) - 1) << - IAF_OFFSET; - } else { - /* - * Adjust the number of classes exported to - * user space. - */ - md->pmd_nclass--; - KASSERT(md->pmd_nclass == 2, - ("[core,%d] unexpected nclass %d", __LINE__, - md->pmd_nclass)); - } + iaf_initialize(md, maxcpu, core_iaf_npmc, core_iaf_width); + core_pmcmask |= ((1ULL << core_iaf_npmc) - 1) << IAF_OFFSET; } PMCDBG(MDP,INI,1,"core-init pmcmask=0x%jx iafri=%d", core_pmcmask, From owner-svn-src-stable-7@FreeBSD.ORG Thu Sep 16 15:19:39 2010 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 663111065696; Thu, 16 Sep 2010 15:19:39 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 54D658FC1B; Thu, 16 Sep 2010 15:19:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8GFJdnW095964; Thu, 16 Sep 2010 15:19:39 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8GFJdvl095962; Thu, 16 Sep 2010 15:19:39 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201009161519.o8GFJdvl095962@svn.freebsd.org> From: Fabien Thomas Date: Thu, 16 Sep 2010 15:19:39 +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: r212743 - stable/7/lib/libpmc 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, 16 Sep 2010 15:19:39 -0000 Author: fabient Date: Thu Sep 16 15:19:39 2010 New Revision: 212743 URL: http://svn.freebsd.org/changeset/base/212743 Log: MFC r212224: Fix invalid class removal when IAF is not the last class. Keep IAF class with 0 PMC and change the alias in libpmc to IAP. Modified: stable/7/lib/libpmc/libpmc.c Directory Properties: stable/7/lib/libpmc/ (props changed) Modified: stable/7/lib/libpmc/libpmc.c ============================================================================== --- stable/7/lib/libpmc/libpmc.c Thu Sep 16 15:19:23 2010 (r212742) +++ stable/7/lib/libpmc/libpmc.c Thu Sep 16 15:19:39 2010 (r212743) @@ -2597,7 +2597,8 @@ pmc_init(void) */ cpu_has_iaf_counters = 0; for (t = 0; t < cpu_info.pm_nclass; t++) - if (cpu_info.pm_classes[t].pm_class == PMC_CLASS_IAF) + if (cpu_info.pm_classes[t].pm_class == PMC_CLASS_IAF && + cpu_info.pm_classes[t].pm_num > 0) cpu_has_iaf_counters = 1; #endif @@ -2610,9 +2611,8 @@ pmc_init(void) #define PMC_MDEP_INIT_INTEL_V2(C) do { \ PMC_MDEP_INIT(C); \ - if (cpu_has_iaf_counters) \ - pmc_class_table[n++] = &iaf_class_table_descr; \ - else \ + pmc_class_table[n++] = &iaf_class_table_descr; \ + if (!cpu_has_iaf_counters) \ pmc_mdep_event_aliases = \ C##_aliases_without_iaf; \ pmc_class_table[n] = &C##_class_table_descr; \ From owner-svn-src-stable-7@FreeBSD.ORG Thu Sep 16 15:22:30 2010 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 A4A13106564A; Thu, 16 Sep 2010 15:22:30 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8891D8FC12; Thu, 16 Sep 2010 15:22:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8GFMU4q096196; Thu, 16 Sep 2010 15:22:30 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8GFMUI8096191; Thu, 16 Sep 2010 15:22:30 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201009161522.o8GFMUI8096191@svn.freebsd.org> From: Fabien Thomas Date: Thu, 16 Sep 2010 15:22: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: r212745 - stable/7/usr.sbin/pmcstat 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, 16 Sep 2010 15:22:30 -0000 Author: fabient Date: Thu Sep 16 15:22:30 2010 New Revision: 212745 URL: http://svn.freebsd.org/changeset/base/212745 Log: MFC r212176: When an asm location cannot be resolved to a function the cost will be spread as small value and then filtered by the threshold. As a first step solution display the number of event that cannot be resolved as a valid function location. Modified: stable/7/usr.sbin/pmcstat/pmcpl_callgraph.c stable/7/usr.sbin/pmcstat/pmcpl_calltree.c stable/7/usr.sbin/pmcstat/pmcstat_log.c stable/7/usr.sbin/pmcstat/pmcstat_log.h Directory Properties: stable/7/usr.sbin/pmcstat/ (props changed) Modified: stable/7/usr.sbin/pmcstat/pmcpl_callgraph.c ============================================================================== --- stable/7/usr.sbin/pmcstat/pmcpl_callgraph.c Thu Sep 16 15:21:15 2010 (r212744) +++ stable/7/usr.sbin/pmcstat/pmcpl_callgraph.c Thu Sep 16 15:22:30 2010 (r212745) @@ -149,6 +149,8 @@ pmcstat_cgnode_hash_lookup_pc(struct pmc */ if ((sym = pmcstat_symbol_search(image, pc)) != NULL) pc = sym->ps_start; + else + pmcstat_stats.ps_samples_unknown_function++; for (hash = i = 0; i < sizeof(uintfptr_t); i++) hash += (pc >> i) & 0xFF; Modified: stable/7/usr.sbin/pmcstat/pmcpl_calltree.c ============================================================================== --- stable/7/usr.sbin/pmcstat/pmcpl_calltree.c Thu Sep 16 15:21:15 2010 (r212744) +++ stable/7/usr.sbin/pmcstat/pmcpl_calltree.c Thu Sep 16 15:22:30 2010 (r212745) @@ -615,6 +615,8 @@ pmcpl_ct_node_hash_lookup_pc(struct pmcp */ if ((sym = pmcstat_symbol_search(image, pc)) != NULL) pc = sym->ps_start; + else + pmcstat_stats.ps_samples_unknown_function++; for (hash = i = 0; i < (int)sizeof(uintfptr_t); i++) hash += (pc >> i) & 0xFF; Modified: stable/7/usr.sbin/pmcstat/pmcstat_log.c ============================================================================== --- stable/7/usr.sbin/pmcstat/pmcstat_log.c Thu Sep 16 15:21:15 2010 (r212744) +++ stable/7/usr.sbin/pmcstat/pmcstat_log.c Thu Sep 16 15:22:30 2010 (r212745) @@ -2170,6 +2170,7 @@ pmcstat_shutdown_logging(void) PRINT("#samples/total", samples_total); PRINT("#samples/unclaimed", samples_unknown_offset); PRINT("#samples/unknown-object", samples_indeterminable); + PRINT("#samples/unknown-function", samples_unknown_function); PRINT("#callchain/dubious-frames", callchain_dubious_frames); } Modified: stable/7/usr.sbin/pmcstat/pmcstat_log.h ============================================================================== --- stable/7/usr.sbin/pmcstat/pmcstat_log.h Thu Sep 16 15:21:15 2010 (r212744) +++ stable/7/usr.sbin/pmcstat/pmcstat_log.h Thu Sep 16 15:22:30 2010 (r212745) @@ -164,6 +164,7 @@ struct pmcstat_stats { int ps_samples_skipped; /* #samples filtered out for any reason */ int ps_samples_unknown_offset; /* #samples of rank 0 not in a map */ int ps_samples_indeterminable; /* #samples in indeterminable images */ + int ps_samples_unknown_function;/* #samples with unknown function at offset */ int ps_callchain_dubious_frames;/* #dubious frame pointers seen */ }; extern struct pmcstat_stats pmcstat_stats; /* statistics */ From owner-svn-src-stable-7@FreeBSD.ORG Thu Sep 16 15:42:57 2010 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 0F4BD1065670; Thu, 16 Sep 2010 15:42:57 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F24AB8FC26; Thu, 16 Sep 2010 15:42:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8GFguCe097018; Thu, 16 Sep 2010 15:42:56 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8GFgu6j097016; Thu, 16 Sep 2010 15:42:56 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201009161542.o8GFgu6j097016@svn.freebsd.org> From: Matthew D Fleming Date: Thu, 16 Sep 2010 15:42:56 +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: r212748 - stable/7/sys/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: Thu, 16 Sep 2010 15:42:57 -0000 Author: mdf Date: Thu Sep 16 15:42:56 2010 New Revision: 212748 URL: http://svn.freebsd.org/changeset/base/212748 Log: MFC r212153: Fix UP build. Modified: stable/7/sys/kern/sched_ule.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/sched_ule.c ============================================================================== --- stable/7/sys/kern/sched_ule.c Thu Sep 16 15:42:11 2010 (r212747) +++ stable/7/sys/kern/sched_ule.c Thu Sep 16 15:42:56 2010 (r212748) @@ -1885,8 +1885,10 @@ sched_switch(struct thread *td, struct t srqflag = (flags & SW_PREEMPT) ? SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED : SRQ_OURSELF|SRQ_YIELDING; +#ifdef SMP if (THREAD_CAN_MIGRATE(td) && !THREAD_CAN_SCHED(td, ts->ts_cpu)) ts->ts_cpu = sched_pickcpu(td, 0); +#endif if (ts->ts_cpu == cpuid) tdq_add(tdq, td, srqflag); else { From owner-svn-src-stable-7@FreeBSD.ORG Sat Sep 18 00:46:06 2010 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 0DA691065673; Sat, 18 Sep 2010 00:46:06 +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 F09BD8FC0A; Sat, 18 Sep 2010 00:46:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8I0k5eY047015; Sat, 18 Sep 2010 00:46:05 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8I0k5MC047013; Sat, 18 Sep 2010 00:46:05 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201009180046.o8I0k5MC047013@svn.freebsd.org> From: Xin LI Date: Sat, 18 Sep 2010 00:46:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212808 - stable/7/usr.bin/gzip 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, 18 Sep 2010 00:46:06 -0000 Author: delphij Date: Sat Sep 18 00:46:05 2010 New Revision: 212808 URL: http://svn.freebsd.org/changeset/base/212808 Log: MFC r211475: Check return value of dup(), it could be -1 when the system is running out of file descriptors for instance. Found with: Coverity Prevent(tm) CID: 6084 Modified: stable/7/usr.bin/gzip/unpack.c Directory Properties: stable/7/usr.bin/gzip/ (props changed) Modified: stable/7/usr.bin/gzip/unpack.c ============================================================================== --- stable/7/usr.bin/gzip/unpack.c Sat Sep 18 00:44:55 2010 (r212807) +++ stable/7/usr.bin/gzip/unpack.c Sat Sep 18 00:46:05 2010 (r212808) @@ -312,7 +312,14 @@ unpack(int in, int out, char *pre, size_ { unpack_descriptor_t unpackd; - unpack_parse_header(dup(in), dup(out), pre, prelen, bytes_in, &unpackd); + in = dup(in); + if (in == -1) + maybe_err("dup"); + out = dup(out); + if (out == -1) + maybe_err("dup"); + + unpack_parse_header(in, out, pre, prelen, bytes_in, &unpackd); unpack_decode(&unpackd, bytes_in); unpack_descriptor_fini(&unpackd); From owner-svn-src-stable-7@FreeBSD.ORG Sat Sep 18 08:18:56 2010 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 D2DA51065774; Sat, 18 Sep 2010 08:18:56 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B934B8FC13; Sat, 18 Sep 2010 08:18:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8I8IuCk057263; Sat, 18 Sep 2010 08:18:56 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8I8Iu5F057260; Sat, 18 Sep 2010 08:18:56 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009180818.o8I8Iu5F057260@svn.freebsd.org> From: Marius Strobl Date: Sat, 18 Sep 2010 08:18:56 +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: r212815 - stable/7/sys/sparc64/sparc64 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, 18 Sep 2010 08:18:57 -0000 Author: marius Date: Sat Sep 18 08:18:56 2010 New Revision: 212815 URL: http://svn.freebsd.org/changeset/base/212815 Log: MFC: r212619 Remove redundant raising of the PIL to PIL_TICK as the respective locore code already did that. Modified: stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/mp_machdep.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Sat Sep 18 08:18:53 2010 (r212814) +++ stable/7/sys/sparc64/sparc64/machdep.c Sat Sep 18 08:18:56 2010 (r212815) @@ -576,7 +576,6 @@ sparc64_init(caddr_t mdp, u_long o1, u_l * enable them. */ intr_init2(); - wrpr(pil, 0, PIL_TICK); wrpr(pstate, 0, PSTATE_KERNEL); /* Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Sat Sep 18 08:18:53 2010 (r212814) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Sat Sep 18 08:18:56 2010 (r212815) @@ -436,7 +436,6 @@ cpu_mp_bootstrap(struct pcpu *pc) cpu_setregs(pc); /* Enable interrupts. */ - wrpr(pil, 0, PIL_TICK); wrpr(pstate, 0, PSTATE_KERNEL); /* Start the (S)TICK interrupts. */ From owner-svn-src-stable-7@FreeBSD.ORG Sat Sep 18 08:20:41 2010 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 6FF6010656C0; Sat, 18 Sep 2010 08:20:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE4A88FC18; Sat, 18 Sep 2010 08:20:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8I8Kd4M057409; Sat, 18 Sep 2010 08:20:39 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8I8KdfV057406; Sat, 18 Sep 2010 08:20:39 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009180820.o8I8KdfV057406@svn.freebsd.org> From: Marius Strobl Date: Sat, 18 Sep 2010 08:20:39 +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: r212817 - in stable/7/sys: sparc64/sparc64 sun4v/sun4v 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, 18 Sep 2010 08:20:41 -0000 Author: marius Date: Sat Sep 18 08:20:39 2010 New Revision: 212817 URL: http://svn.freebsd.org/changeset/base/212817 Log: MFC: r212620 Remove a KASSERT which will also trigger for perfectly valid combinations of small maxsize and "large" (including BUS_SPACE_UNRESTRICTED) nsegments parameters. Generally using a presz of 0 (which indeed might indicate the use of bogus parameters for DMA tag creation) is not fatal, it just means that no additional DVMA space will be preallocated. Modified: stable/7/sys/sparc64/sparc64/iommu.c stable/7/sys/sun4v/sun4v/hviommu.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/sparc64/iommu.c ============================================================================== --- stable/7/sys/sparc64/sparc64/iommu.c Sat Sep 18 08:20:36 2010 (r212816) +++ stable/7/sys/sparc64/sparc64/iommu.c Sat Sep 18 08:20:39 2010 (r212817) @@ -874,9 +874,6 @@ iommu_dvmamap_create(bus_dma_tag_t dt, i */ maxpre = imin(dt->dt_nsegments, IOMMU_MAX_PRE_SEG); presz = dt->dt_maxsize / maxpre; - KASSERT(presz != 0, ("%s: bogus preallocation size , nsegments = %d, " - "maxpre = %d, maxsize = %lu", __func__, dt->dt_nsegments, maxpre, - dt->dt_maxsize)); for (i = 1; i < maxpre && totsz < IOMMU_MAX_PRE; i++) { currsz = round_io_page(ulmin(presz, IOMMU_MAX_PRE - totsz)); error = iommu_dvma_valloc(dt, is, *mapp, currsz); Modified: stable/7/sys/sun4v/sun4v/hviommu.c ============================================================================== --- stable/7/sys/sun4v/sun4v/hviommu.c Sat Sep 18 08:20:36 2010 (r212816) +++ stable/7/sys/sun4v/sun4v/hviommu.c Sat Sep 18 08:20:39 2010 (r212817) @@ -513,9 +513,6 @@ hviommu_dvmamap_create(bus_dma_tag_t dt, */ maxpre = imin(dt->dt_nsegments, IOMMU_MAX_PRE_SEG); presz = dt->dt_maxsize / maxpre; - KASSERT(presz != 0, ("hviommu_dvmamap_create: bogus preallocation size " - ", nsegments = %d, maxpre = %d, maxsize = %lu", dt->dt_nsegments, - maxpre, dt->dt_maxsize)); for (i = 1; i < maxpre && totsz < IOMMU_MAX_PRE; i++) { currsz = round_io_page(ulmin(presz, IOMMU_MAX_PRE - totsz)); error = hviommu_dvma_valloc(dt, him, *mapp, currsz);