From owner-svn-src-stable@FreeBSD.ORG Sun Mar 8 00:11:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39D13106567C; Sun, 8 Mar 2009 00:11:29 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5E888FC14; Sun, 8 Mar 2009 00:11:26 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n280BQgN066372; Sun, 8 Mar 2009 00:11:26 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n280BQfQ066371; Sun, 8 Mar 2009 00:11:26 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200903080011.n280BQfQ066371@svn.freebsd.org> From: Luigi Rizzo Date: Sun, 8 Mar 2009 00:11:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189502 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Mar 2009 00:11:30 -0000 Author: luigi Date: Sun Mar 8 00:11:26 2009 New Revision: 189502 URL: http://svn.freebsd.org/changeset/base/189502 Log: MFC rev.188571 Clarify and reimplement the bioq API so that bioq_disksort() has the correct behaviour (sorting by distance from the current head position in the scan direction) and bioq_insert_head() and bioq_insert_tail() have a well defined (and useful) behaviour, especially when intermixed with calls to bioq_disksort(). See the original commit log for more details. NO API/ABI changes (except from fixing bugs and defining unspecified behaviour that no code should rely on). Modified: stable/7/sys/kern/subr_disk.c Modified: stable/7/sys/kern/subr_disk.c ============================================================================== --- stable/7/sys/kern/subr_disk.c Sat Mar 7 22:17:44 2009 (r189501) +++ stable/7/sys/kern/subr_disk.c Sun Mar 8 00:11:26 2009 (r189502) @@ -5,6 +5,10 @@ * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- + * + * The bioq_disksort() (and the specification of the bioq API) + * have been written by Luigi Rizzo and Fabio Checconi under the same + * license as above. */ #include @@ -63,11 +67,86 @@ disk_err(struct bio *bp, const char *wha /* * BIO queue implementation + * + * Please read carefully the description below before making any change + * to the code, or you might change the behaviour of the data structure + * in undesirable ways. + * + * A bioq stores disk I/O request (bio), normally sorted according to + * the distance of the requested position (bio->bio_offset) from the + * current head position (bioq->last_offset) in the scan direction, i.e. + * + * (uoff_t)(bio_offset - last_offset) + * + * Note that the cast to unsigned (uoff_t) is fundamental to insure + * that the distance is computed in the scan direction. + * + * The main methods for manipulating the bioq are: + * + * bioq_disksort() performs an ordered insertion; + * + * bioq_first() return the head of the queue, without removing; + * + * bioq_takefirst() return and remove the head of the queue, + * updating the 'current head position' as + * bioq->last_offset = bio->bio_offset + bio->bio_length; + * + * When updating the 'current head position', we assume that the result of + * bioq_takefirst() is dispatched to the device, so bioq->last_offset + * represents the head position once the request is complete. + * + * If the bioq is manipulated using only the above calls, it starts + * with a sorted sequence of requests with bio_offset >= last_offset, + * possibly followed by another sorted sequence of requests with + * 0 <= bio_offset < bioq->last_offset + * + * NOTE: historical behaviour was to ignore bio->bio_length in the + * update, but its use tracks the head position in a better way. + * Historical behaviour was also to update the head position when + * the request under service is complete, rather than when the + * request is extracted from the queue. However, the current API + * has no method to update the head position; secondly, once + * a request has been submitted to the disk, we have no idea of + * the actual head position, so the final one is our best guess. + * + * --- Direct queue manipulation --- + * + * A bioq uses an underlying TAILQ to store requests, so we also + * export methods to manipulate the TAILQ, in particular: + * + * bioq_insert_tail() insert an entry at the end. + * It also creates a 'barrier' so all subsequent + * insertions through bioq_disksort() will end up + * after this entry; + * + * bioq_insert_head() insert an entry at the head, update + * bioq->last_offset = bio->bio_offset so that + * all subsequent insertions through bioq_disksort() + * will end up after this entry; + * + * bioq_remove() remove a generic element from the queue, act as + * bioq_takefirst() if invoked on the head of the queue. + * + * The semantic of these methods is the same of the operations + * on the underlying TAILQ, but with additional guarantees on + * subsequent bioq_disksort() calls. E.g. bioq_insert_tail() + * can be useful for making sure that all previous ops are flushed + * to disk before continuing. + * + * Updating bioq->last_offset on a bioq_insert_head() guarantees + * that the bio inserted with the last bioq_insert_head() will stay + * at the head of the queue even after subsequent bioq_disksort(). + * + * Note that when the direct queue manipulation functions are used, + * the queue may contain multiple inversion points (i.e. more than + * two sorted sequences of requests). + * */ void bioq_init(struct bio_queue_head *head) { + TAILQ_INIT(&head->queue); head->last_offset = 0; head->insert_point = NULL; @@ -76,14 +155,13 @@ bioq_init(struct bio_queue_head *head) void bioq_remove(struct bio_queue_head *head, struct bio *bp) { - if (bp == head->insert_point) { - head->last_offset = bp->bio_offset; - head->insert_point = TAILQ_NEXT(bp, bio_queue); - if (head->insert_point == NULL) { - head->last_offset = 0; - head->insert_point = TAILQ_FIRST(&head->queue); - } - } + + if (bp == TAILQ_FIRST(&head->queue)) + head->last_offset = bp->bio_offset + bp->bio_length; + + if (bp == head->insert_point) + head->insert_point = NULL; + TAILQ_REMOVE(&head->queue, bp, bio_queue); } @@ -100,8 +178,7 @@ void bioq_insert_head(struct bio_queue_head *head, struct bio *bp) { - if (TAILQ_EMPTY(&head->queue)) - head->insert_point = bp; + head->last_offset = bp->bio_offset; TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); } @@ -109,9 +186,8 @@ void bioq_insert_tail(struct bio_queue_head *head, struct bio *bp) { - if (TAILQ_EMPTY(&head->queue)) - head->insert_point = bp; TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue); + head->insert_point = bp; } struct bio * @@ -133,65 +209,42 @@ bioq_takefirst(struct bio_queue_head *he } /* + * Compute the sorting key. The cast to unsigned is + * fundamental for correctness, see the description + * near the beginning of the file. + */ +static inline uoff_t +bioq_bio_key(struct bio_queue_head *head, struct bio *bp) +{ + + return ((uoff_t)(bp->bio_offset - head->last_offset)); +} + +/* * Seek sort for disks. * - * The disksort algorithm sorts all requests in a single queue while keeping - * track of the current position of the disk with insert_point and - * last_offset. last_offset is the offset of the last block sent to disk, or - * 0 once we reach the end. insert_point points to the first buf after - * last_offset, and is used to slightly speed up insertions. Blocks are - * always sorted in ascending order and the queue always restarts at 0. - * This implements the one-way scan which optimizes disk seek times. + * Sort all requests in a single queue while keeping + * track of the current position of the disk with last_offset. + * See above for details. */ void -bioq_disksort(bioq, bp) - struct bio_queue_head *bioq; - struct bio *bp; +bioq_disksort(struct bio_queue_head *head, struct bio *bp) { - struct bio *bq; - struct bio *bn; + struct bio *cur, *prev = NULL; + uoff_t key = bioq_bio_key(head, bp); - /* - * If the queue is empty then it's easy. - */ - if (bioq_first(bioq) == NULL) { - bioq_insert_tail(bioq, bp); - return; - } - /* - * Optimize for sequential I/O by seeing if we go at the tail. - */ - bq = TAILQ_LAST(&bioq->queue, bio_queue); - if (bp->bio_offset > bq->bio_offset) { - TAILQ_INSERT_AFTER(&bioq->queue, bq, bp, bio_queue); - return; - } - /* - * Pick our scan start based on the last request. A poor man's - * binary search. - */ - if (bp->bio_offset >= bioq->last_offset) { - bq = bioq->insert_point; - /* - * If we're before the next bio and after the last offset, - * update insert_point; - */ - if (bp->bio_offset < bq->bio_offset) { - bioq->insert_point = bp; - TAILQ_INSERT_BEFORE(bq, bp, bio_queue); - return; - } - } else - bq = TAILQ_FIRST(&bioq->queue); - if (bp->bio_offset < bq->bio_offset) { - TAILQ_INSERT_BEFORE(bq, bp, bio_queue); - return; - } - /* Insertion sort */ - while ((bn = TAILQ_NEXT(bq, bio_queue)) != NULL) { - if (bp->bio_offset < bn->bio_offset) - break; - bq = bn; + cur = TAILQ_FIRST(&head->queue); + + if (head->insert_point) + cur = head->insert_point; + + while (cur != NULL && key >= bioq_bio_key(head, cur)) { + prev = cur; + cur = TAILQ_NEXT(cur, bio_queue); } - TAILQ_INSERT_AFTER(&bioq->queue, bq, bp, bio_queue); + + if (prev == NULL) + TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); + else + TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue); } From owner-svn-src-stable@FreeBSD.ORG Sun Mar 8 11:12:23 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC27C1065670; Sun, 8 Mar 2009 11:12:23 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C95BE8FC0A; Sun, 8 Mar 2009 11:12:23 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n28BCN1W081887; Sun, 8 Mar 2009 11:12:23 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n28BCNTP081886; Sun, 8 Mar 2009 11:12:23 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200903081112.n28BCNTP081886@svn.freebsd.org> From: Dmitry Chagin Date: Sun, 8 Mar 2009 11:12:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189530 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Mar 2009 11:12:24 -0000 Author: dchagin Date: Sun Mar 8 11:12:23 2009 New Revision: 189530 URL: http://svn.freebsd.org/changeset/base/189530 Log: MFC r189232, r189313: Fix range-check error introduced in r182292. Panic in case the ncpus == 0. it helps to catch bugs in the callers. Approved by: kib (mentor) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_smp.c Modified: stable/7/sys/kern/subr_smp.c ============================================================================== --- stable/7/sys/kern/subr_smp.c Sun Mar 8 10:58:37 2009 (r189529) +++ stable/7/sys/kern/subr_smp.c Sun Mar 8 11:12:23 2009 (r189530) @@ -358,9 +358,11 @@ smp_rendezvous_cpus(cpumask_t map, return; } - for (i = 0; i < mp_maxid; i++) + for (i = 0; i <= mp_maxid; i++) if (((1 << i) & map) != 0 && !CPU_ABSENT(i)) ncpus++; + if (ncpus == 0) + panic("ncpus is 0 with map=0x%x", map); /* obtain rendezvous lock */ mtx_lock_spin(&smp_ipi_mtx); From owner-svn-src-stable@FreeBSD.ORG Sun Mar 8 11:20:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4FD61065680; Sun, 8 Mar 2009 11:20:54 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C1D0F8FC0A; Sun, 8 Mar 2009 11:20:54 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n28BKsAI082113; Sun, 8 Mar 2009 11:20:54 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n28BKsjh082112; Sun, 8 Mar 2009 11:20:54 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200903081120.n28BKsjh082112@svn.freebsd.org> From: Robert Watson Date: Sun, 8 Mar 2009 11:20:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189531 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Mar 2009 11:20:55 -0000 Author: rwatson Date: Sun Mar 8 11:20:54 2009 New Revision: 189531 URL: http://svn.freebsd.org/changeset/base/189531 Log: Merge missed routing lock fix r186061 from head to stable/7: Dont leak the rnh lock on error. Original change was from thompsa. This may correct routing-related panics seen by uses of ppp, including the following PRs: PR: 132215, 132222, 132404 Reported by: Ethan Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/rtsock.c Modified: stable/7/sys/net/rtsock.c ============================================================================== --- stable/7/sys/net/rtsock.c Sun Mar 8 11:12:23 2009 (r189530) +++ stable/7/sys/net/rtsock.c Sun Mar 8 11:20:54 2009 (r189531) @@ -629,10 +629,10 @@ route_output(struct mbuf *m, struct sock rt->rt_ifa->ifa_addr))) { RT_UNLOCK(rt); RADIX_NODE_HEAD_LOCK(rnh); - if ((error = rt_getifa_fib(&info, - rt->rt_fibnum)) != 0) - senderr(error); + error = rt_getifa_fib(&info, rt->rt_fibnum); RADIX_NODE_HEAD_UNLOCK(rnh); + if (error != 0) + senderr(error); RT_LOCK(rt); } if (info.rti_ifa != NULL && From owner-svn-src-stable@FreeBSD.ORG Sun Mar 8 16:19:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29DEC106566B; Sun, 8 Mar 2009 16:19:30 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 16F028FC08; Sun, 8 Mar 2009 16:19:30 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n28GJTeV087551; Sun, 8 Mar 2009 16:19:29 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n28GJTxT087550; Sun, 8 Mar 2009 16:19:29 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200903081619.n28GJTxT087550@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 8 Mar 2009 16:19: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: r189536 - stable/7/sys/powerpc/powerpc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Mar 2009 16:19:30 -0000 Author: nwhitehorn Date: Sun Mar 8 16:19:29 2009 New Revision: 189536 URL: http://svn.freebsd.org/changeset/base/189536 Log: Fix a mismerge from head that I somehow missed last night. This caused builds with KDB enabled to fail. Pointy hat to: me Modified: stable/7/sys/powerpc/powerpc/trap_subr.S Modified: stable/7/sys/powerpc/powerpc/trap_subr.S ============================================================================== --- stable/7/sys/powerpc/powerpc/trap_subr.S Sun Mar 8 16:16:55 2009 (r189535) +++ stable/7/sys/powerpc/powerpc/trap_subr.S Sun Mar 8 16:19:29 2009 (r189536) @@ -515,12 +515,9 @@ CNAME(ppc_db_trap): */ dbtrap: /* Write the trap vector to SPRG3 by computing LR & 0xff00 */ - mflr %r1 - andi. %r1,%r1,0xff00 - mtsprg3 %r1 - - lis %r1,(tmpstk+TMPSTKSZ-16)@ha /* get new SP */ - addi %r1,%r1,(tmpstk+TMPSTKSZ-16)@l + mflr %r31 + andi. %r31,%r31,0xff00 + mtsprg3 %r31 FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ From owner-svn-src-stable@FreeBSD.ORG Mon Mar 9 08:18:40 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB94B1065679; Mon, 9 Mar 2009 08:18:40 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE1DA8FC1E; Mon, 9 Mar 2009 08:18:40 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n298IeFx014686; Mon, 9 Mar 2009 08:18:40 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n298Ie9S014684; Mon, 9 Mar 2009 08:18:40 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903090818.n298Ie9S014684@svn.freebsd.org> From: Robert Noland Date: Mon, 9 Mar 2009 08:18:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189568 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 08:18:41 -0000 Author: rnoland Date: Mon Mar 9 08:18:40 2009 New Revision: 189568 URL: http://svn.freebsd.org/changeset/base/189568 Log: Merge r189285 Disable INTx when enabling MSI/MSIX This addresses interrupt storms that were noticed after enabling MSI in drm. I think this is due to a loose interpretation of the PCI 2.3 spec, which states that a function using MSI is prohibitted from using INTx. It appears that some vendors interpretted that to mean that they should handle it in hardware, while others felt it was the drivers responsibility. This fix will also likely resolve interrupt storm related issues with devices other than drm. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c stable/7/sys/dev/pci/pcireg.h Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 9 08:17:46 2009 (r189567) +++ stable/7/sys/dev/pci/pci.c Mon Mar 9 08:18:40 2009 (r189568) @@ -2845,6 +2845,8 @@ pci_setup_intr(device_t dev, device_t ch } mte->mte_handlers++; } + /* Disable INTx if we are using MSI/MSIX */ + pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); bad: if (error) { (void)bus_generic_teardown_intr(dev, child, irq, @@ -2899,6 +2901,8 @@ pci_teardown_intr(device_t dev, device_t if (mte->mte_handlers == 0) pci_mask_msix(child, rid - 1); } + /* Restore INTx capability for MSI/MSIX */ + pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); } error = bus_generic_teardown_intr(dev, child, irq, cookie); if (device_get_parent(child) == dev && rid > 0) Modified: stable/7/sys/dev/pci/pcireg.h ============================================================================== --- stable/7/sys/dev/pci/pcireg.h Mon Mar 9 08:17:46 2009 (r189567) +++ stable/7/sys/dev/pci/pcireg.h Mon Mar 9 08:18:40 2009 (r189568) @@ -60,6 +60,7 @@ #define PCIM_CMD_PERRESPEN 0x0040 #define PCIM_CMD_SERRESPEN 0x0100 #define PCIM_CMD_BACKTOBACK 0x0200 +#define PCIM_CMD_INTxDIS 0x0400 #define PCIR_STATUS 0x06 #define PCIM_STATUS_CAPPRESENT 0x0010 #define PCIM_STATUS_66CAPABLE 0x0020 From owner-svn-src-stable@FreeBSD.ORG Mon Mar 9 08:25:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C29C31065677; Mon, 9 Mar 2009 08:25:05 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AF62B8FC1D; Mon, 9 Mar 2009 08:25:05 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n298P53k014945; Mon, 9 Mar 2009 08:25:05 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n298P5RU014944; Mon, 9 Mar 2009 08:25:05 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903090825.n298P5RU014944@svn.freebsd.org> From: Robert Noland Date: Mon, 9 Mar 2009 08:25: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: r189569 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 08:25:06 -0000 Author: rnoland Date: Mon Mar 9 08:25:05 2009 New Revision: 189569 URL: http://svn.freebsd.org/changeset/base/189569 Log: Merge r189367,189447 Extend the management of PCIM_CMD_INTxDIS. We now explicitly enable INTx during bus_setup_intr() if it is needed. Several of the ata drivers were managing this bit internally. This is better handled in pci and it should work for all drivers now. We also mask INTx during bus_teardown_intr() by setting this bit. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 9 08:18:40 2009 (r189568) +++ stable/7/sys/dev/pci/pci.c Mon Mar 9 08:25:05 2009 (r189569) @@ -2796,14 +2796,24 @@ pci_setup_intr(device_t dev, device_t ch if (error) return (error); - /* - * If this is a direct child, check to see if the interrupt is - * MSI or MSI-X. If so, ask our parent to map the MSI and give - * us the address and data register values. If we fail for some - * reason, teardown the interrupt handler. - */ + /* If this is not a direct child, just bail out. */ + if (device_get_parent(child) != dev) { + *cookiep = cookie; + return(0); + } + rid = rman_get_rid(irq); - if (device_get_parent(child) == dev && rid > 0) { + if (rid == 0) { + /* Make sure that INTx is enabled */ + pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); + } else { + /* + * Check to see if the interrupt is MSI or MSI-X. + * Ask our parent to map the MSI and give + * us the address and data register values. + * If we fail for some reason, teardown the + * interrupt handler. + */ dinfo = device_get_ivars(child); if (dinfo->cfg.msi.msi_alloc > 0) { if (dinfo->cfg.msi.msi_addr == 0) { @@ -2845,7 +2855,8 @@ pci_setup_intr(device_t dev, device_t ch } mte->mte_handlers++; } - /* Disable INTx if we are using MSI/MSIX */ + + /* Make sure that INTx is disabled if we are using MSI/MSIX */ pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); bad: if (error) { @@ -2867,16 +2878,24 @@ pci_teardown_intr(device_t dev, device_t struct pci_devinfo *dinfo; int error, rid; - /* - * If this is a direct child, check to see if the interrupt is - * MSI or MSI-X. If so, decrement the appropriate handlers - * count and mask the MSI-X message, or disable MSI messages - * if the count drops to 0. - */ if (irq == NULL || !(rman_get_flags(irq) & RF_ACTIVE)) return (EINVAL); + + /* If this isn't a direct child, just bail out */ + if (device_get_parent(child) != dev) + return(bus_generic_teardown_intr(dev, child, irq, cookie)); + rid = rman_get_rid(irq); - if (device_get_parent(child) == dev && rid > 0) { + if (rid == 0) { + /* Mask INTx */ + pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); + } else { + /* + * Check to see if the interrupt is MSI or MSI-X. If so, + * decrement the appropriate handlers count and mask the + * MSI-X message, or disable MSI messages if the count + * drops to 0. + */ dinfo = device_get_ivars(child); rle = resource_list_find(&dinfo->resources, SYS_RES_IRQ, rid); if (rle->res != irq) @@ -2901,11 +2920,9 @@ pci_teardown_intr(device_t dev, device_t if (mte->mte_handlers == 0) pci_mask_msix(child, rid - 1); } - /* Restore INTx capability for MSI/MSIX */ - pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); } error = bus_generic_teardown_intr(dev, child, irq, cookie); - if (device_get_parent(child) == dev && rid > 0) + if (rid > 0) KASSERT(error == 0, ("%s: generic teardown failed for MSI/MSI-X", __func__)); return (error); From owner-svn-src-stable@FreeBSD.ORG Mon Mar 9 14:04:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9779C106566C; Mon, 9 Mar 2009 14:04:18 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 842EF8FC0A; Mon, 9 Mar 2009 14:04:18 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n29E4IAN028499; Mon, 9 Mar 2009 14:04:18 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n29E4IVt028498; Mon, 9 Mar 2009 14:04:18 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200903091404.n29E4IVt028498@svn.freebsd.org> From: Christian Brueffer Date: Mon, 9 Mar 2009 14:04: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: r189582 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 14:04:19 -0000 Author: brueffer Date: Mon Mar 9 14:04:18 2009 New Revision: 189582 URL: http://svn.freebsd.org/changeset/base/189582 Log: MFC: r189298 Xref glxsb(4). Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/crypto.4 stable/7/share/man/man4/igb.4 (props changed) Modified: stable/7/share/man/man4/crypto.4 ============================================================================== --- stable/7/share/man/man4/crypto.4 Mon Mar 9 13:32:19 2009 (r189581) +++ stable/7/share/man/man4/crypto.4 Mon Mar 9 14:04:18 2009 (r189582) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 1, 2007 +.Dd March 3, 2009 .Dt CRYPTO 4 .Os .Sh NAME @@ -105,6 +105,7 @@ asymmetric cryptographic features are po crypto access device .El .Sh SEE ALSO +.Xr glxsb 4 , .Xr hifn 4 , .Xr ipsec 4 , .Xr padlock 4 , From owner-svn-src-stable@FreeBSD.ORG Mon Mar 9 17:07:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD1C310656CD; Mon, 9 Mar 2009 17:07:27 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99DD18FC18; Mon, 9 Mar 2009 17:07:27 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n29H7RCa032306; Mon, 9 Mar 2009 17:07:27 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n29H7R4i032305; Mon, 9 Mar 2009 17:07:27 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <200903091707.n29H7R4i032305@svn.freebsd.org> From: Ruslan Ermilov Date: Mon, 9 Mar 2009 17:07:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189586 - stable/7/share/misc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 17:07:29 -0000 Author: ru Date: Mon Mar 9 17:07:27 2009 New Revision: 189586 URL: http://svn.freebsd.org/changeset/base/189586 Log: MFC: Spell 'Yugoslav' correctly. Modified: stable/7/share/misc/ (props changed) stable/7/share/misc/iso3166 Modified: stable/7/share/misc/iso3166 ============================================================================== --- stable/7/share/misc/iso3166 Mon Mar 9 17:05:31 2009 (r189585) +++ stable/7/share/misc/iso3166 Mon Mar 9 17:07:27 2009 (r189586) @@ -442,8 +442,8 @@ ZW ZWE 716 Zimbabwe # Previously covered by the entry ET # # Newsletter III-57, 1993-07-16 -# Macedonia, the former Yugolslav Republic of, -# Previously covered by the entry YU +# Macedonia, the former Yugoslav Republic of, +# Previously covered by the entry YU # # Newsletter III-58, 1993-07-16 # Afghanistan, changing information not included in this file From owner-svn-src-stable@FreeBSD.ORG Mon Mar 9 17:42:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 305461066155; Mon, 9 Mar 2009 17:42:36 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE9CE8FC16; Mon, 9 Mar 2009 17:42:34 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n29HgY1b033209; Mon, 9 Mar 2009 17:42:34 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n29HgYpS033208; Mon, 9 Mar 2009 17:42:34 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903091742.n29HgYpS033208@svn.freebsd.org> From: Robert Noland Date: Mon, 9 Mar 2009 17:42:34 +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: r189591 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 17:42:52 -0000 Author: rnoland Date: Mon Mar 9 17:42:34 2009 New Revision: 189591 URL: http://svn.freebsd.org/changeset/base/189591 Log: Manual merge of r189368 due to different ata layout in stable. Remove the local management of INTx as this is now taken care of by pci. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-chipset.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/7/sys/dev/ata/ata-chipset.c Mon Mar 9 17:42:18 2009 (r189590) +++ stable/7/sys/dev/ata/ata-chipset.c Mon Mar 9 17:42:34 2009 (r189591) @@ -528,10 +528,6 @@ ata_ahci_chipinit(device_t dev) ctlr->allocate = ata_ahci_allocate; ctlr->setmode = ata_sata_setmode; - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); - /* announce we support the HW */ version = ATA_INL(ctlr->r_res2, ATA_AHCI_VS); device_printf(dev, @@ -1100,10 +1096,6 @@ ata_ali_chipinit(device_t dev) if ((ctlr->chip->chipid == ATA_ALI_5288) && (ata_ahci_chipinit(dev) != ENXIO)) return 0; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); break; case ALINEW: @@ -1894,10 +1886,6 @@ ata_intel_chipinit(device_t dev) ctlr->setmode = ata_intel_sata_setmode; else ctlr->setmode = ata_sata_setmode; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); } return 0; } @@ -2658,10 +2646,6 @@ ata_marvell_edma_chipinit(device_t dev) /* unmask host controller interrupts we want */ ATA_OUTL(ctlr->r_res1, 0x01d64, 0x000000ff/*HC0*/ | 0x0001fe00/*HC1*/ | /*(1<<19) | (1<<20) | (1<<21) |*/(1<<22) | (1<<24) | (0x7f << 25)); - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); return 0; } @@ -3201,11 +3185,6 @@ ata_nvidia_chipinit(device_t dev) /* enable device and PHY state change interrupts */ ATA_OUTB(ctlr->r_res2, offset + 1, 0xdd); } - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); - } ctlr->setmode = ata_sata_setmode; } @@ -4604,10 +4583,6 @@ ata_sii_chipinit(device_t dev) ATA_OUTL(ctlr->r_res1, 0x0040, 0x80000000); DELAY(10000); ATA_OUTL(ctlr->r_res1, 0x0040, 0x0000000f); - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); break; case SIIMEMIO: @@ -5359,10 +5334,6 @@ ata_sis_chipinit(device_t dev) &ctlr->r_rid2, RF_ACTIVE))) { ctlr->allocate = ata_sis_allocate; ctlr->reset = ata_sis_reset; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); } ctlr->setmode = ata_sata_setmode; return 0; @@ -5551,10 +5522,6 @@ ata_via_chipinit(device_t dev) &ctlr->r_rid2, RF_ACTIVE))) { ctlr->allocate = ata_via_allocate; ctlr->reset = ata_via_reset; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); } if (ctlr->chip->cfg2 & VIABAR) { From owner-svn-src-stable@FreeBSD.ORG Tue Mar 10 17:28:24 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33893106566C; Tue, 10 Mar 2009 17:28:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 185418FC21; Tue, 10 Mar 2009 17:28:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AHSOHA068718; Tue, 10 Mar 2009 17:28:24 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2AHSNFH068714; Tue, 10 Mar 2009 17:28:23 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903101728.n2AHSNFH068714@svn.freebsd.org> From: John Baldwin Date: Tue, 10 Mar 2009 17:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189634 - in stable/7/sys: . compat/freebsd32 contrib/pf dev/cxgb i386/ibcs2 kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 17:28:29 -0000 Author: jhb Date: Tue Mar 10 17:28:23 2009 New Revision: 189634 URL: http://svn.freebsd.org/changeset/base/189634 Log: MFC: Push down Giant inside sysctl. Modified: stable/7/sys/ (props changed) stable/7/sys/compat/freebsd32/freebsd32_misc.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/i386/ibcs2/ibcs2_sysi86.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/kern_xxx.c Modified: stable/7/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 10 17:28:23 2009 (r189634) @@ -1966,7 +1966,6 @@ freebsd32_sysctl(struct thread *td, stru error = copyin(uap->name, name, uap->namelen * sizeof(int)); if (error) return (error); - mtx_lock(&Giant); if (uap->oldlenp) oldlen = fuword32(uap->oldlenp); else @@ -1975,12 +1974,10 @@ freebsd32_sysctl(struct thread *td, stru uap->old, &oldlen, 1, uap->new, uap->newlen, &j, SCTL_MASK32); if (error && error != ENOMEM) - goto done2; + return (error); if (uap->oldlenp) suword32(uap->oldlenp, j); -done2: - mtx_unlock(&Giant); - return (error); + return (0); } int Modified: stable/7/sys/i386/ibcs2/ibcs2_sysi86.c ============================================================================== --- stable/7/sys/i386/ibcs2/ibcs2_sysi86.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/i386/ibcs2/ibcs2_sysi86.c Tue Mar 10 17:28:23 2009 (r189634) @@ -74,15 +74,11 @@ ibcs2_sysi86(struct thread *td, struct i case SETNAME: { /* set hostname given string w/ len <= 7 chars */ int name[2]; - int error; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, 0, 0, 0, - args->arg, 7, 0, 0); - mtx_unlock(&Giant); - return (error); + return (userland_sysctl(td, name, 2, 0, 0, 0, + args->arg, 7, 0, 0)); } case SI86_MEM: /* size of physical memory */ Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:28:23 2009 (r189634) @@ -70,6 +70,7 @@ static struct sx sysctllock; #define SYSCTL_LOCK() sx_xlock(&sysctllock) #define SYSCTL_UNLOCK() sx_xunlock(&sysctllock) +#define SYSCTL_LOCK_ASSERT() sx_assert(&sysctllock, SX_XLOCKED) #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") static int sysctl_root(SYSCTL_HANDLER_ARGS); @@ -666,6 +667,8 @@ name2oid (char *name, int *oid, int *len struct sysctl_oid_list *lsp = &sysctl__children; char *p; + SYSCTL_LOCK_ASSERT(); + if (!*name) return (ENOENT); @@ -722,6 +725,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR int error, oid[CTL_MAXNAME], len; struct sysctl_oid *op = 0; + SYSCTL_LOCK_ASSERT(); + if (!req->newlen) return (ENOENT); if (req->newlen >= MAXPATHLEN) /* XXX arbitrary, undocumented */ @@ -1066,14 +1071,12 @@ kernel_sysctl(struct thread *td, int *na req.lock = REQ_LOCKED; SYSCTL_LOCK(); - error = sysctl_root(0, name, namelen, &req); + SYSCTL_UNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); - SYSCTL_UNLOCK(); - if (error && error != ENOMEM) return (error); @@ -1098,6 +1101,11 @@ kernel_sysctlbyname(struct thread *td, c oid[1] = 3; /* name2oid */ oidlen = sizeof(oid); + /* + * XXX: Prone to a possible race condition between lookup and + * execution? Maybe put locking around it? + */ + error = kernel_sysctl(td, oid, 2, oid, &oidlen, (void *)name, strlen(name), &plen, flags); if (error) @@ -1250,6 +1258,8 @@ sysctl_root(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; int error, indx, lvl; + SYSCTL_LOCK_ASSERT(); + error = sysctl_find_oid(arg1, arg2, &oid, &indx, req); if (error) return (error); @@ -1304,7 +1314,11 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif + + /* XXX: Handlers are not guaranteed to be Giant safe! */ + mtx_lock(&Giant); error = oid->oid_handler(oid, arg1, arg2, req); + mtx_unlock(&Giant); return (error); } @@ -1332,20 +1346,16 @@ __sysctl(struct thread *td, struct sysct if (error) return (error); - mtx_lock(&Giant); - error = userland_sysctl(td, name, uap->namelen, uap->old, uap->oldlenp, 0, uap->new, uap->newlen, &j, 0); if (error && error != ENOMEM) - goto done2; + return (error); if (uap->oldlenp) { int i = copyout(&j, uap->oldlenp, sizeof(j)); if (i) - error = i; + return (i); } -done2: - mtx_unlock(&Giant); return (error); } @@ -1405,11 +1415,11 @@ userland_sysctl(struct thread *td, int * uio_yield(); } + SYSCTL_UNLOCK(); + if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); - SYSCTL_UNLOCK(); - if (error && error != ENOMEM) return (error); @@ -1421,217 +1431,3 @@ userland_sysctl(struct thread *td, int * } return (error); } - -#ifdef COMPAT_43 -#include -#include - -#define KINFO_PROC (0<<8) -#define KINFO_RT (1<<8) -#define KINFO_VNODE (2<<8) -#define KINFO_FILE (3<<8) -#define KINFO_METER (4<<8) -#define KINFO_LOADAVG (5<<8) -#define KINFO_CLOCKRATE (6<<8) - -/* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ -#define KINFO_BSDI_SYSINFO (101<<8) - -/* - * XXX this is bloat, but I hope it's better here than on the potentially - * limited kernel stack... -Peter - */ - -static struct { - int bsdi_machine; /* "i386" on BSD/386 */ -/* ^^^ this is an offset to the string, relative to the struct start */ - char *pad0; - long pad1; - long pad2; - long pad3; - u_long pad4; - u_long pad5; - u_long pad6; - - int bsdi_ostype; /* "BSD/386" on BSD/386 */ - int bsdi_osrelease; /* "1.1" on BSD/386 */ - long pad7; - long pad8; - char *pad9; - - long pad10; - long pad11; - int pad12; - long pad13; - quad_t pad14; - long pad15; - - struct timeval pad16; - /* we dont set this, because BSDI's uname used gethostname() instead */ - int bsdi_hostname; /* hostname on BSD/386 */ - - /* the actual string data is appended here */ - -} bsdi_si; - -/* - * this data is appended to the end of the bsdi_si structure during copyout. - * The "char *" offsets are relative to the base of the bsdi_si struct. - * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings - * should not exceed the length of the buffer here... (or else!! :-) - */ -static char bsdi_strings[80]; /* It had better be less than this! */ - -#ifndef _SYS_SYSPROTO_H_ -struct getkerninfo_args { - int op; - char *where; - size_t *size; - int arg; -}; -#endif -int -ogetkerninfo(struct thread *td, struct getkerninfo_args *uap) -{ - int error, name[6]; - size_t size; - u_int needed = 0; - - mtx_lock(&Giant); - - switch (uap->op & 0xff00) { - - case KINFO_RT: - name[0] = CTL_NET; - name[1] = PF_ROUTE; - name[2] = 0; - name[3] = (uap->op & 0xff0000) >> 16; - name[4] = uap->op & 0xff; - name[5] = uap->arg; - error = userland_sysctl(td, name, 6, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_VNODE: - name[0] = CTL_KERN; - name[1] = KERN_VNODE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_PROC: - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = uap->op & 0xff; - name[3] = uap->arg; - error = userland_sysctl(td, name, 4, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_FILE: - name[0] = CTL_KERN; - name[1] = KERN_FILE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_METER: - name[0] = CTL_VM; - name[1] = VM_TOTAL; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_LOADAVG: - name[0] = CTL_VM; - name[1] = VM_LOADAVG; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_CLOCKRATE: - name[0] = CTL_KERN; - name[1] = KERN_CLOCKRATE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_BSDI_SYSINFO: { - /* - * this is pretty crude, but it's just enough for uname() - * from BSDI's 1.x libc to work. - * - * *size gives the size of the buffer before the call, and - * the amount of data copied after a successful call. - * If successful, the return value is the amount of data - * available, which can be larger than *size. - * - * BSDI's 2.x product apparently fails with ENOMEM if *size - * is too small. - */ - - u_int left; - char *s; - - bzero((char *)&bsdi_si, sizeof(bsdi_si)); - bzero(bsdi_strings, sizeof(bsdi_strings)); - - s = bsdi_strings; - - bsdi_si.bsdi_ostype = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, ostype); - s += strlen(s) + 1; - - bsdi_si.bsdi_osrelease = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, osrelease); - s += strlen(s) + 1; - - bsdi_si.bsdi_machine = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, machine); - s += strlen(s) + 1; - - needed = sizeof(bsdi_si) + (s - bsdi_strings); - - if ((uap->where == NULL) || (uap->size == NULL)) { - /* process is asking how much buffer to supply.. */ - size = needed; - error = 0; - break; - } - - if ((error = copyin(uap->size, &size, sizeof(size))) != 0) - break; - - /* if too much buffer supplied, trim it down */ - if (size > needed) - size = needed; - - /* how much of the buffer is remaining */ - left = size; - - if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0) - break; - - /* is there any point in continuing? */ - if (left > sizeof(bsdi_si)) { - left -= sizeof(bsdi_si); - error = copyout(&bsdi_strings, - uap->where + sizeof(bsdi_si), left); - } - break; - } - - default: - error = EOPNOTSUPP; - break; - } - if (error == 0) { - td->td_retval[0] = needed ? needed : size; - if (uap->size) { - error = copyout(&size, uap->size, sizeof(size)); - } - } - mtx_unlock(&Giant); - return (error); -} -#endif /* COMPAT_43 */ Modified: stable/7/sys/kern/kern_xxx.c ============================================================================== --- stable/7/sys/kern/kern_xxx.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/kern/kern_xxx.c Tue Mar 10 17:28:23 2009 (r189634) @@ -42,9 +42,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #if defined(COMPAT_43) @@ -61,16 +63,12 @@ ogethostname(td, uap) struct gethostname_args *uap; { int name[2]; - int error; size_t len = uap->len; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, uap->hostname, &len, - 1, 0, 0, 0, 0); - mtx_unlock(&Giant); - return(error); + return (userland_sysctl(td, name, 2, uap->hostname, &len, + 1, 0, 0, 0, 0)); } #ifndef _SYS_SYSPROTO_H_ @@ -86,15 +84,11 @@ osethostname(td, uap) register struct sethostname_args *uap; { int name[2]; - int error; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, - uap->len, 0, 0); - mtx_unlock(&Giant); - return (error); + return (userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, + uap->len, 0, 0)); } #ifndef _SYS_SYSPROTO_H_ @@ -145,6 +139,212 @@ oquota(td, uap) return (ENOSYS); } + +#define KINFO_PROC (0<<8) +#define KINFO_RT (1<<8) +#define KINFO_VNODE (2<<8) +#define KINFO_FILE (3<<8) +#define KINFO_METER (4<<8) +#define KINFO_LOADAVG (5<<8) +#define KINFO_CLOCKRATE (6<<8) + +/* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ +#define KINFO_BSDI_SYSINFO (101<<8) + +/* + * XXX this is bloat, but I hope it's better here than on the potentially + * limited kernel stack... -Peter + */ + +static struct { + int bsdi_machine; /* "i386" on BSD/386 */ +/* ^^^ this is an offset to the string, relative to the struct start */ + char *pad0; + long pad1; + long pad2; + long pad3; + u_long pad4; + u_long pad5; + u_long pad6; + + int bsdi_ostype; /* "BSD/386" on BSD/386 */ + int bsdi_osrelease; /* "1.1" on BSD/386 */ + long pad7; + long pad8; + char *pad9; + + long pad10; + long pad11; + int pad12; + long pad13; + quad_t pad14; + long pad15; + + struct timeval pad16; + /* we dont set this, because BSDI's uname used gethostname() instead */ + int bsdi_hostname; /* hostname on BSD/386 */ + + /* the actual string data is appended here */ + +} bsdi_si; + +/* + * this data is appended to the end of the bsdi_si structure during copyout. + * The "char *" offsets are relative to the base of the bsdi_si struct. + * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings + * should not exceed the length of the buffer here... (or else!! :-) + */ +static char bsdi_strings[80]; /* It had better be less than this! */ + +#ifndef _SYS_SYSPROTO_H_ +struct getkerninfo_args { + int op; + char *where; + size_t *size; + int arg; +}; +#endif +int +ogetkerninfo(struct thread *td, struct getkerninfo_args *uap) +{ + int error, name[6]; + size_t size; + u_int needed = 0; + + switch (uap->op & 0xff00) { + + case KINFO_RT: + name[0] = CTL_NET; + name[1] = PF_ROUTE; + name[2] = 0; + name[3] = (uap->op & 0xff0000) >> 16; + name[4] = uap->op & 0xff; + name[5] = uap->arg; + error = userland_sysctl(td, name, 6, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_VNODE: + name[0] = CTL_KERN; + name[1] = KERN_VNODE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_PROC: + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = uap->op & 0xff; + name[3] = uap->arg; + error = userland_sysctl(td, name, 4, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_FILE: + name[0] = CTL_KERN; + name[1] = KERN_FILE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_METER: + name[0] = CTL_VM; + name[1] = VM_TOTAL; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_LOADAVG: + name[0] = CTL_VM; + name[1] = VM_LOADAVG; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_CLOCKRATE: + name[0] = CTL_KERN; + name[1] = KERN_CLOCKRATE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_BSDI_SYSINFO: { + /* + * this is pretty crude, but it's just enough for uname() + * from BSDI's 1.x libc to work. + * + * *size gives the size of the buffer before the call, and + * the amount of data copied after a successful call. + * If successful, the return value is the amount of data + * available, which can be larger than *size. + * + * BSDI's 2.x product apparently fails with ENOMEM if *size + * is too small. + */ + + u_int left; + char *s; + + bzero((char *)&bsdi_si, sizeof(bsdi_si)); + bzero(bsdi_strings, sizeof(bsdi_strings)); + + s = bsdi_strings; + + bsdi_si.bsdi_ostype = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, ostype); + s += strlen(s) + 1; + + bsdi_si.bsdi_osrelease = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, osrelease); + s += strlen(s) + 1; + + bsdi_si.bsdi_machine = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, machine); + s += strlen(s) + 1; + + needed = sizeof(bsdi_si) + (s - bsdi_strings); + + if ((uap->where == NULL) || (uap->size == NULL)) { + /* process is asking how much buffer to supply.. */ + size = needed; + error = 0; + break; + } + + if ((error = copyin(uap->size, &size, sizeof(size))) != 0) + break; + + /* if too much buffer supplied, trim it down */ + if (size > needed) + size = needed; + + /* how much of the buffer is remaining */ + left = size; + + if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0) + break; + + /* is there any point in continuing? */ + if (left > sizeof(bsdi_si)) { + left -= sizeof(bsdi_si); + error = copyout(&bsdi_strings, + uap->where + sizeof(bsdi_si), left); + } + break; + } + + default: + error = EOPNOTSUPP; + break; + } + if (error == 0) { + td->td_retval[0] = needed ? needed : size; + if (uap->size) { + error = copyout(&size, uap->size, sizeof(size)); + } + } + return (error); +} #endif /* COMPAT_43 */ /* @@ -173,11 +373,10 @@ uname(td, uap) name[0] = CTL_KERN; name[1] = KERN_OSTYPE; len = sizeof (uap->name->sysname); - mtx_lock(&Giant); error = userland_sysctl(td, name, 2, uap->name->sysname, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0); name[1] = KERN_HOSTNAME; @@ -185,7 +384,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->nodename, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0); name[1] = KERN_OSRELEASE; @@ -193,7 +392,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->release, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->release + sizeof(uap->name->release) - 1, 0); /* @@ -202,7 +401,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->version, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->version + sizeof(uap->name->version) - 1, 0); */ @@ -214,11 +413,11 @@ uname(td, uap) for(us = uap->name->version; *s && *s != ':'; s++) { error = subyte( us++, *s); if (error) - goto done2; + return (error); } error = subyte( us++, 0); if (error) - goto done2; + return (error); name[0] = CTL_HW; name[1] = HW_MACHINE; @@ -226,11 +425,9 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->machine, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0); -done2: - mtx_unlock(&Giant); - return (error); + return (0); } #ifndef _SYS_SYSPROTO_H_ From owner-svn-src-stable@FreeBSD.ORG Tue Mar 10 18:16:04 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59D17106568F; Tue, 10 Mar 2009 18:16:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1EAB98FC22; Tue, 10 Mar 2009 18:16:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AIG40d069872; Tue, 10 Mar 2009 18:16:04 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2AIG3b5069869; Tue, 10 Mar 2009 18:16:03 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903101816.n2AIG3b5069869@svn.freebsd.org> From: John Baldwin Date: Tue, 10 Mar 2009 18:16:03 +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: r189638 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 18:16:10 -0000 Author: jhb Date: Tue Mar 10 18:16:03 2009 New Revision: 189638 URL: http://svn.freebsd.org/changeset/base/189638 Log: MFC: Add sysctl_rename_oid() and use it in device_set_unit(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/subr_bus.c stable/7/sys/sys/sysctl.h Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:16:03 2009 (r189638) @@ -417,6 +417,25 @@ sysctl_add_oid(struct sysctl_ctx_list *c } /* + * Rename an existing oid. + */ +void +sysctl_rename_oid(struct sysctl_oid *oidp, const char *name) +{ + ssize_t len; + char *newname; + void *oldname; + + oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; + len = strlen(name); + newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK); + bcopy(name, newname, len + 1); + newname[len] = '\0'; + oidp->oid_name = newname; + free(oldname, M_SYSCTLOID); +} + +/* * Reparent an existing oid. */ int Modified: stable/7/sys/kern/subr_bus.c ============================================================================== --- stable/7/sys/kern/subr_bus.c Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/kern/subr_bus.c Tue Mar 10 18:16:03 2009 (r189638) @@ -307,6 +307,16 @@ device_sysctl_init(device_t dev) } static void +device_sysctl_update(device_t dev) +{ + devclass_t dc = dev->devclass; + + if (dev->sysctl_tree == NULL) + return; + sysctl_rename_oid(dev->sysctl_tree, dev->nameunit + strlen(dc->name)); +} + +static void device_sysctl_fini(device_t dev) { if (dev->sysctl_tree == NULL) @@ -2396,6 +2406,7 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; return (error); } + device_sysctl_update(dev); dev->state = DS_ATTACHED; devadded(dev); return (0); Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 18:16:03 2009 (r189638) @@ -661,6 +661,7 @@ struct sysctl_oid *sysctl_add_oid(struct int kind, void *arg1, int arg2, int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr); +void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); int sysctl_move_oid(struct sysctl_oid *oidp, struct sysctl_oid_list *parent); int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); From owner-svn-src-stable@FreeBSD.ORG Tue Mar 10 18:57:11 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77B2C106564A; Tue, 10 Mar 2009 18:57:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 625CA8FC1D; Tue, 10 Mar 2009 18:57:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AIvBqU070794; Tue, 10 Mar 2009 18:57:11 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2AIvBWr070786; Tue, 10 Mar 2009 18:57:11 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903101857.n2AIvBWr070786@svn.freebsd.org> From: John Baldwin Date: Tue, 10 Mar 2009 18:57:11 +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: r189640 - in stable/7/sys: . cam/scsi contrib/pf dev/ath/ath_hal dev/cxgb ia64/ia64 ia64/include kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 18:57:12 -0000 Author: jhb Date: Tue Mar 10 18:57:10 2009 New Revision: 189640 URL: http://svn.freebsd.org/changeset/base/189640 Log: MFC: Expand the scope of the sysctllock sx lock to protect the sysctl tree itself. This also includes changes to the ia64 machine check code to defer adding machine check records to the sysctl tree, removing Giant from the CAM code that created dynamic sysctls, and tweaking the teardown of da(4) and cd(4) peripheral devices to not hold locks when freeing the sysctl tree. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_cd.c stable/7/sys/cam/scsi/scsi_da.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ia64/ia64/mca.c stable/7/sys/ia64/include/mca.h stable/7/sys/kern/kern_linker.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/vfs_init.c stable/7/sys/sys/sysctl.h Modified: stable/7/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_cd.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/cam/scsi/scsi_cd.c Tue Mar 10 18:57:10 2009 (r189640) @@ -401,11 +401,6 @@ cdcleanup(struct cam_periph *periph) xpt_print(periph->path, "removing device entry\n"); - if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 - && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { - xpt_print(periph->path, "can't remove sysctl context\n"); - } - /* * In the queued, non-active case, the device in question * has already been removed from the changer run queue. Since this @@ -474,9 +469,14 @@ cdcleanup(struct cam_periph *periph) free(softc->changer, M_DEVBUF); } cam_periph_unlock(periph); + if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 + && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { + xpt_print(periph->path, "can't remove sysctl context\n"); + } + disk_destroy(softc->disk); - cam_periph_lock(periph); free(softc, M_DEVBUF); + cam_periph_lock(periph); } static void @@ -555,8 +555,6 @@ cdsysctlinit(void *context, int pending) snprintf(tmpstr, sizeof(tmpstr), "CAM CD unit %d", periph->unit_number); snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); - mtx_lock(&Giant); - sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= CD_FLAG_SCTX_INIT; softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, @@ -565,7 +563,6 @@ cdsysctlinit(void *context, int pending) if (softc->sysctl_tree == NULL) { printf("cdsysctlinit: unable to allocate sysctl tree\n"); - mtx_unlock(&Giant); cam_periph_release(periph); return; } @@ -579,7 +576,6 @@ cdsysctlinit(void *context, int pending) &softc->minimum_command_size, 0, cdcmdsizesysctl, "I", "Minimum CDB size"); - mtx_unlock(&Giant); cam_periph_release(periph); } Modified: stable/7/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_da.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/cam/scsi/scsi_da.c Tue Mar 10 18:57:10 2009 (r189640) @@ -987,6 +987,8 @@ dacleanup(struct cam_periph *periph) softc = (struct da_softc *)periph->softc; xpt_print(periph->path, "removing device entry\n"); + cam_periph_unlock(periph); + /* * If we can't free the sysctl tree, oh well... */ @@ -995,11 +997,10 @@ dacleanup(struct cam_periph *periph) xpt_print(periph->path, "can't remove sysctl context\n"); } - cam_periph_unlock(periph); disk_destroy(softc->disk); callout_drain(&softc->sendordered_c); - cam_periph_lock(periph); free(softc, M_DEVBUF); + cam_periph_lock(periph); } static void @@ -1078,7 +1079,6 @@ dasysctlinit(void *context, int pending) snprintf(tmpstr, sizeof(tmpstr), "CAM DA unit %d", periph->unit_number); snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); - mtx_lock(&Giant); sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= DA_FLAG_SCTX_INIT; softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, @@ -1086,7 +1086,6 @@ dasysctlinit(void *context, int pending) CTLFLAG_RD, 0, tmpstr); if (softc->sysctl_tree == NULL) { printf("dasysctlinit: unable to allocate sysctl tree\n"); - mtx_unlock(&Giant); cam_periph_release(periph); return; } @@ -1100,7 +1099,6 @@ dasysctlinit(void *context, int pending) &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); - mtx_unlock(&Giant); cam_periph_release(periph); } Modified: stable/7/sys/ia64/ia64/mca.c ============================================================================== --- stable/7/sys/ia64/ia64/mca.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/ia64/ia64/mca.c Tue Mar 10 18:57:10 2009 (r189640) @@ -42,6 +42,16 @@ MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture"); +struct mca_info { + STAILQ_ENTRY(mca_info) mi_link; + char mi_name[32]; + size_t mi_recsz; + char mi_record[0]; +}; + +static STAILQ_HEAD(, mca_info) mca_records = + STAILQ_HEAD_INITIALIZER(mca_records); + int64_t mca_info_size[SAL_INFO_TYPES]; vm_offset_t mca_info_block; struct mtx mca_info_block_lock; @@ -76,14 +86,32 @@ mca_sysctl_handler(SYSCTL_HANDLER_ARGS) } void +ia64_mca_populate(void) +{ + struct mca_info *rec; + + mtx_lock_spin(&mca_info_block_lock); + while (!STAILQ_EMPTY(&mca_records)) { + rec = STAILQ_FIRST(&mca_records); + STAILQ_REMOVE_HEAD(&mca_records, mi_link); + mtx_unlock_spin(&mca_info_block_lock); + (void)SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), + OID_AUTO, rec->mi_name, CTLTYPE_OPAQUE | CTLFLAG_RD, + rec->mi_record, rec->mi_recsz, mca_sysctl_handler, "S,MCA", + "Error record"); + mtx_lock_spin(&mca_info_block_lock); + } + mtx_unlock_spin(&mca_info_block_lock); +} + +void ia64_mca_save_state(int type) { struct ia64_sal_result result; struct mca_record_header *hdr; - struct sysctl_oid *oidp; - char *name, *state; + struct mca_info *rec; uint64_t seqnr; - size_t recsz, totsz; + size_t recsz; /* * Don't try to get the state if we couldn't get the size of @@ -95,9 +123,8 @@ ia64_mca_save_state(int type) if (mca_info_block == 0) return; + mtx_lock_spin(&mca_info_block_lock); while (1) { - mtx_lock_spin(&mca_info_block_lock); - result = ia64_sal_entry(SAL_GET_STATE_INFO, type, 0, mca_info_block, 0, 0, 0, 0); if (result.sal_status < 0) { @@ -111,11 +138,13 @@ ia64_mca_save_state(int type) mtx_unlock_spin(&mca_info_block_lock); - totsz = sizeof(struct sysctl_oid) + recsz + 32; - oidp = malloc(totsz, M_MCA, M_NOWAIT|M_ZERO); - state = (char*)(oidp + 1); - name = state + recsz; - sprintf(name, "%lld", (long long)seqnr); + rec = malloc(sizeof(struct mca_info) + recsz, M_MCA, + M_NOWAIT | M_ZERO); + if (rec == NULL) + /* XXX: Not sure what to do. */ + return; + + sprintf(rec->mi_name, "%lld", (long long)seqnr); mtx_lock_spin(&mca_info_block_lock); @@ -133,24 +162,14 @@ ia64_mca_save_state(int type) mca_info_block, 0, 0, 0, 0); if (seqnr != hdr->rh_seqnr) { mtx_unlock_spin(&mca_info_block_lock); - free(oidp, M_MCA); + free(rec, M_MCA); + mtx_lock_spin(&mca_info_block_lock); continue; } } - bcopy((char*)mca_info_block, state, recsz); - - oidp->oid_parent = &sysctl__hw_mca_children; - oidp->oid_number = OID_AUTO; - oidp->oid_kind = CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_DYN; - oidp->oid_arg1 = state; - oidp->oid_arg2 = recsz; - oidp->oid_name = name; - oidp->oid_handler = mca_sysctl_handler; - oidp->oid_fmt = "S,MCA"; - oidp->oid_descr = "Error record"; - - sysctl_register_oid(oidp); + rec->mi_recsz = recsz; + bcopy((char*)mca_info_block, rec->mi_record, recsz); if (mca_count > 0) { if (seqnr < mca_first) @@ -161,6 +180,7 @@ ia64_mca_save_state(int type) mca_first = mca_last = seqnr; mca_count++; + STAILQ_INSERT_TAIL(&mca_records, rec, mi_link); /* * Clear the state so that we get any other records when @@ -168,8 +188,6 @@ ia64_mca_save_state(int type) */ result = ia64_sal_entry(SAL_CLEAR_STATE_INFO, type, 0, 0, 0, 0, 0, 0); - - mtx_unlock_spin(&mca_info_block_lock); } } Modified: stable/7/sys/ia64/include/mca.h ============================================================================== --- stable/7/sys/ia64/include/mca.h Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/ia64/include/mca.h Tue Mar 10 18:57:10 2009 (r189640) @@ -239,6 +239,7 @@ struct mca_pcidev_reg { #ifdef _KERNEL void ia64_mca_init(void); +void ia64_mca_populate(void); void ia64_mca_save_state(int); #endif /* _KERNEL */ Modified: stable/7/sys/kern/kern_linker.c ============================================================================== --- stable/7/sys/kern/kern_linker.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/kern_linker.c Tue Mar 10 18:57:10 2009 (r189640) @@ -292,10 +292,10 @@ linker_file_register_sysctls(linker_file if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_register_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static void @@ -309,10 +309,10 @@ linker_file_unregister_sysctls(linker_fi if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_unregister_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static int Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:57:10 2009 (r189640) @@ -64,24 +64,41 @@ static MALLOC_DEFINE(M_SYSCTLOID, "sysct static MALLOC_DEFINE(M_SYSCTLTMP, "sysctltmp", "sysctl temp output buffer"); /* - * Locking - this locks the sysctl tree in memory. + * The sysctllock protects the MIB tree. It also protects sysctl + * contexts used with dynamic sysctls. The sysctl_register_oid() and + * sysctl_unregister_oid() routines require the sysctllock to already + * be held, so the sysctl_lock() and sysctl_unlock() routines are + * provided for the few places in the kernel which need to use that + * API rather than using the dynamic API. Use of the dynamic API is + * strongly encouraged for most code. + * + * This lock is also used to serialize userland sysctl requests. Some + * sysctls wire user memory, and serializing the requests limits the + * amount of wired user memory in use. */ static struct sx sysctllock; -#define SYSCTL_LOCK() sx_xlock(&sysctllock) -#define SYSCTL_UNLOCK() sx_xunlock(&sysctllock) -#define SYSCTL_LOCK_ASSERT() sx_assert(&sysctllock, SX_XLOCKED) +#define SYSCTL_SLOCK() sx_slock(&sysctllock) +#define SYSCTL_SUNLOCK() sx_sunlock(&sysctllock) +#define SYSCTL_XLOCK() sx_xlock(&sysctllock) +#define SYSCTL_XUNLOCK() sx_xunlock(&sysctllock) +#define SYSCTL_ASSERT_XLOCKED() sx_assert(&sysctllock, SA_XLOCKED) +#define SYSCTL_ASSERT_LOCKED() sx_assert(&sysctllock, SA_LOCKED) #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") static int sysctl_root(SYSCTL_HANDLER_ARGS); struct sysctl_oid_list sysctl__children; /* root list */ +static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, + int recurse); + static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) { struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, list, oid_link) { if (strcmp(oidp->oid_name, name) == 0) { return (oidp); @@ -95,6 +112,19 @@ sysctl_find_oidname(const char *name, st * * Order by number in each list. */ +void +sysctl_lock(void) +{ + + SYSCTL_XLOCK(); +} + +void +sysctl_unlock(void) +{ + + SYSCTL_XUNLOCK(); +} void sysctl_register_oid(struct sysctl_oid *oidp) @@ -107,6 +137,7 @@ sysctl_register_oid(struct sysctl_oid *o * First check if another oid with the same name already * exists in the parent's list. */ + SYSCTL_ASSERT_XLOCKED(); p = sysctl_find_oidname(oidp->oid_name, parent); if (p != NULL) { if ((p->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -159,6 +190,7 @@ sysctl_unregister_oid(struct sysctl_oid struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); error = ENOENT; if (oidp->oid_number == OID_AUTO) { error = EINVAL; @@ -190,6 +222,12 @@ sysctl_ctx_init(struct sysctl_ctx_list * if (c == NULL) { return (EINVAL); } + + /* + * No locking here, the caller is responsible for not adding + * new nodes to a context until after this function has + * returned. + */ TAILQ_INIT(c); return (0); } @@ -208,8 +246,9 @@ sysctl_ctx_free(struct sysctl_ctx_list * * XXX This algorithm is a hack. But I don't know any * XXX better solution for now... */ + SYSCTL_XLOCK(); TAILQ_FOREACH(e, clist, link) { - error = sysctl_remove_oid(e->entry, 0, 0); + error = sysctl_remove_oid_locked(e->entry, 0, 0); if (error) break; } @@ -226,19 +265,22 @@ sysctl_ctx_free(struct sysctl_ctx_list * sysctl_register_oid(e1->entry); e1 = TAILQ_PREV(e1, sysctl_ctx_list, link); } - if (error) + if (error) { + SYSCTL_XUNLOCK(); return(EBUSY); + } /* Now really delete the entries */ e = TAILQ_FIRST(clist); while (e != NULL) { e1 = TAILQ_NEXT(e, link); - error = sysctl_remove_oid(e->entry, 1, 0); + error = sysctl_remove_oid_locked(e->entry, 1, 0); if (error) panic("sysctl_remove_oid: corrupt tree, entry: %s", e->entry->oid_name); free(e, M_SYSCTLOID); e = e1; } + SYSCTL_XUNLOCK(); return (error); } @@ -248,6 +290,7 @@ sysctl_ctx_entry_add(struct sysctl_ctx_l { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_XLOCKED(); if (clist == NULL || oidp == NULL) return(NULL); e = malloc(sizeof(struct sysctl_ctx_entry), M_SYSCTLOID, M_WAITOK); @@ -262,6 +305,7 @@ sysctl_ctx_entry_find(struct sysctl_ctx_ { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_LOCKED(); if (clist == NULL || oidp == NULL) return(NULL); TAILQ_FOREACH(e, clist, link) { @@ -283,13 +327,17 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l if (clist == NULL || oidp == NULL) return (EINVAL); + SYSCTL_XLOCK(); e = sysctl_ctx_entry_find(clist, oidp); if (e != NULL) { TAILQ_REMOVE(clist, e, link); + SYSCTL_XUNLOCK(); free(e, M_SYSCTLOID); return (0); - } else + } else { + SYSCTL_XUNLOCK(); return (ENOENT); + } } /* @@ -301,9 +349,21 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse) { + int error; + + SYSCTL_XLOCK(); + error = sysctl_remove_oid_locked(oidp, del, recurse); + SYSCTL_XUNLOCK(); + return (error); +} + +static int +sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) +{ struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); if (oidp == NULL) return(EINVAL); if ((oidp->oid_kind & CTLFLAG_DYN) == 0) { @@ -322,7 +382,8 @@ sysctl_remove_oid(struct sysctl_oid *oid SLIST_FOREACH(p, SYSCTL_CHILDREN(oidp), oid_link) { if (!recurse) return (ENOTEMPTY); - error = sysctl_remove_oid(p, del, recurse); + error = sysctl_remove_oid_locked(p, del, + recurse); if (error) return (error); } @@ -367,6 +428,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c if (parent == NULL) return(NULL); /* Check if the node already exists, otherwise create it */ + SYSCTL_XLOCK(); oidp = sysctl_find_oidname(name, parent); if (oidp != NULL) { if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -374,8 +436,10 @@ sysctl_add_oid(struct sysctl_ctx_list *c /* Update the context */ if (clist != NULL) sysctl_ctx_entry_add(clist, oidp); + SYSCTL_XUNLOCK(); return (oidp); } else { + SYSCTL_XUNLOCK(); printf("can't re-use a leaf (%s)!\n", name); return (NULL); } @@ -413,6 +477,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c sysctl_ctx_entry_add(clist, oidp); /* Register this oid */ sysctl_register_oid(oidp); + SYSCTL_XUNLOCK(); return (oidp); } @@ -426,12 +491,14 @@ sysctl_rename_oid(struct sysctl_oid *oid char *newname; void *oldname; - oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; len = strlen(name); newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK); bcopy(name, newname, len + 1); newname[len] = '\0'; + SYSCTL_XLOCK(); + oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; oidp->oid_name = newname; + SYSCTL_XUNLOCK(); free(oldname, M_SYSCTLOID); } @@ -443,15 +510,21 @@ sysctl_move_oid(struct sysctl_oid *oid, { struct sysctl_oid *oidp; - if (oid->oid_parent == parent) + SYSCTL_XLOCK(); + if (oid->oid_parent == parent) { + SYSCTL_XUNLOCK(); return (0); + } oidp = sysctl_find_oidname(oid->oid_name, parent); - if (oidp != NULL) + if (oidp != NULL) { + SYSCTL_XUNLOCK(); return (EEXIST); + } sysctl_unregister_oid(oid); oid->oid_parent = parent; oid->oid_number = OID_AUTO; sysctl_register_oid(oid); + SYSCTL_XUNLOCK(); return (0); } @@ -466,8 +539,10 @@ sysctl_register_all(void *arg) struct sysctl_oid **oidp; SYSCTL_INIT(); + SYSCTL_XLOCK(); SET_FOREACH(oidp, sysctl_set) sysctl_register_oid(*oidp); + SYSCTL_XUNLOCK(); } SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); @@ -497,6 +572,7 @@ sysctl_sysctl_debug_dump_node(struct sys int k; struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, l, oid_link) { for (k=0; koid_number; @@ -686,7 +764,7 @@ name2oid (char *name, int *oid, int *len struct sysctl_oid_list *lsp = &sysctl__children; char *p; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!*name) return (ENOENT); @@ -744,7 +822,7 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR int error, oid[CTL_MAXNAME], len; struct sysctl_oid *op = 0; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!req->newlen) return (ENOENT); @@ -1089,9 +1167,9 @@ kernel_sysctl(struct thread *td, int *na req.newfunc = sysctl_new_kernel; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_SLOCK(); error = sysctl_root(0, name, namelen, &req); - SYSCTL_UNLOCK(); + SYSCTL_SUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); @@ -1123,6 +1201,9 @@ kernel_sysctlbyname(struct thread *td, c /* * XXX: Prone to a possible race condition between lookup and * execution? Maybe put locking around it? + * + * Userland is just as racy, so I think the current implementation + * is fine. */ error = kernel_sysctl(td, oid, 2, oid, &oidlen, @@ -1234,6 +1315,7 @@ sysctl_find_oid(int *name, u_int namelen struct sysctl_oid *oid; int indx; + SYSCTL_ASSERT_LOCKED(); oid = SLIST_FIRST(&sysctl__children); indx = 0; while (oid && indx < CTL_MAXNAME) { @@ -1277,7 +1359,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; int error, indx, lvl; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); error = sysctl_find_oid(arg1, arg2, &oid, &indx, req); if (error) @@ -1355,7 +1437,7 @@ struct sysctl_args { int __sysctl(struct thread *td, struct sysctl_args *uap) { - int error, name[CTL_MAXNAME]; + int error, i, name[CTL_MAXNAME]; size_t j; if (uap->namelen > CTL_MAXNAME || uap->namelen < 2) @@ -1371,7 +1453,7 @@ __sysctl(struct thread *td, struct sysct if (error && error != ENOMEM) return (error); if (uap->oldlenp) { - int i = copyout(&j, uap->oldlenp, sizeof(j)); + i = copyout(&j, uap->oldlenp, sizeof(j)); if (i) return (i); } @@ -1423,7 +1505,7 @@ userland_sysctl(struct thread *td, int * req.newfunc = sysctl_new_user; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_XLOCK(); for (;;) { req.oldidx = 0; @@ -1434,7 +1516,7 @@ userland_sysctl(struct thread *td, int * uio_yield(); } - SYSCTL_UNLOCK(); + SYSCTL_XUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); Modified: stable/7/sys/kern/vfs_init.c ============================================================================== --- stable/7/sys/kern/vfs_init.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/vfs_init.c Tue Mar 10 18:57:10 2009 (r189640) @@ -165,12 +165,15 @@ vfs_register(struct vfsconf *vfc) * preserved by re-registering the oid after modifying its * number. */ + sysctl_lock(); SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; sysctl_register_oid(oidp); + break; } + sysctl_unlock(); /* * Initialise unused ``struct vfsops'' fields, to use Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 18:57:10 2009 (r189640) @@ -685,6 +685,8 @@ int userland_sysctl(struct thread *td, i size_t *retval, int flags); int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req); +void sysctl_lock(void); +void sysctl_unlock(void); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); #else /* !_KERNEL */ From owner-svn-src-stable@FreeBSD.ORG Tue Mar 10 19:33:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 167671065670; Tue, 10 Mar 2009 19:33:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 007388FC18; Tue, 10 Mar 2009 19:33:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AJXoCW071665; Tue, 10 Mar 2009 19:33:50 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2AJXoej071656; Tue, 10 Mar 2009 19:33:50 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903101933.n2AJXoej071656@svn.freebsd.org> From: John Baldwin Date: Tue, 10 Mar 2009 19:33:50 +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: r189644 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs kern sys vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 19:33:51 -0000 Author: jhb Date: Tue Mar 10 19:33:50 2009 New Revision: 189644 URL: http://svn.freebsd.org/changeset/base/189644 Log: MFC: Add a flag to tag individual sysctl leaf nodes as MPSAFE. Tag the following nodes as MPSAFE: - All standalone INT/LONG sysctls. - kern.proc.* - All name-cache related sysctls. - vm.loadavg - vm.vmtotal - vm.stats.(sys|vm).* - sysctl.name2oid - kern.ident, kern.osrelease, kern.version, etc. - kern.arandom - security.jail.jailed - kern.devname Other changes: - Remove GIANT_REQUIRED from vmtotal(). - Add conditional Giant locking around the vrele() in sysctl_kern_proc_pathname(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_devs.c stable/7/sys/kern/kern_jail.c stable/7/sys/kern/kern_mib.c stable/7/sys/kern/kern_proc.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/vfs_cache.c stable/7/sys/sys/sysctl.h stable/7/sys/vm/vm_meter.c Modified: stable/7/sys/fs/devfs/devfs_devs.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_devs.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/fs/devfs/devfs_devs.c Tue Mar 10 19:33:50 2009 (r189644) @@ -103,8 +103,9 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_PROC(_kern, OID_AUTO, devname, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY, - NULL, 0, sysctl_devname, "", "devname(3) handler"); +SYSCTL_PROC(_kern, OID_AUTO, devname, + CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, + NULL, 0, sysctl_devname, "", "devname(3) handler"); SYSCTL_INT(_debug_sizeof, OID_AUTO, cdev, CTLFLAG_RD, 0, sizeof(struct cdev), "sizeof(struct cdev)"); Modified: stable/7/sys/kern/kern_jail.c ============================================================================== --- stable/7/sys/kern/kern_jail.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_jail.c Tue Mar 10 19:33:50 2009 (r189644) @@ -1791,8 +1791,9 @@ sysctl_jail_list(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_OID(_security_jail, OID_AUTO, list, CTLTYPE_STRUCT | CTLFLAG_RD, - NULL, 0, sysctl_jail_list, "S", "List of active jails"); +SYSCTL_OID(_security_jail, OID_AUTO, list, + CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_jail_list, "S", "List of active jails"); static int sysctl_jail_jailed(SYSCTL_HANDLER_ARGS) @@ -1804,8 +1805,9 @@ sysctl_jail_jailed(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_PROC(_security_jail, OID_AUTO, jailed, CTLTYPE_INT | CTLFLAG_RD, - NULL, 0, sysctl_jail_jailed, "I", "Process in jail?"); +SYSCTL_PROC(_security_jail, OID_AUTO, jailed, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_jail_jailed, "I", "Process in jail?"); #ifdef DDB DB_SHOW_COMMAND(jails, db_show_jails) Modified: stable/7/sys/kern/kern_mib.c ============================================================================== --- stable/7/sys/kern/kern_mib.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_mib.c Tue Mar 10 19:33:50 2009 (r189644) @@ -86,19 +86,19 @@ SYSCTL_NODE(, OID_AUTO, regression, CTLF "Regression test MIB"); #endif -SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD, +SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD|CTLFLAG_MPSAFE, kern_ident, 0, "Kernel identifier"); -SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD|CTLFLAG_MPSAFE, osrelease, 0, "Operating system release"); SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD, 0, BSD, "Operating system revision"); -SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD|CTLFLAG_MPSAFE, version, 0, "Kernel version"); -SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE, ostype, 0, "Operating system type"); /* @@ -164,8 +164,9 @@ sysctl_kern_arnd(SYSCTL_HANDLER_ARGS) return (SYSCTL_OUT(req, buf, len)); } -SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLTYPE_OPAQUE | CTLFLAG_RD, - NULL, 0, sysctl_kern_arnd, "", "arc4rand"); +SYSCTL_PROC(_kern, KERN_ARND, arandom, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_kern_arnd, "", "arc4rand"); static int sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) @@ -247,7 +248,7 @@ sysctl_hostname(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname, - CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON, + CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON|CTLFLAG_MPSAFE, 0, 0, sysctl_hostname, "A", "Hostname"); static int regression_securelevel_nonmonotonic = 0; Modified: stable/7/sys/kern/kern_proc.c ============================================================================== --- stable/7/sys/kern/kern_proc.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_proc.c Tue Mar 10 19:33:50 2009 (r189644) @@ -1281,7 +1281,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER struct proc *p; struct vnode *vp; char *retbuf, *freebuf; - int error; + int error, vfslocked; if (arglen != 1) return (EINVAL); @@ -1307,7 +1307,9 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER if (*pidp != -1) PROC_UNLOCK(p); error = vn_fullpath(req->td, vp, &retbuf, &freebuf); + vfslocked = VFS_LOCK_GIANT(vp->v_mount); vrele(vp); + VFS_UNLOCK_GIANT(vfslocked); if (error) return (error); error = SYSCTL_OUT(req, retbuf, strlen(retbuf) + 1); @@ -1795,80 +1797,83 @@ repeat: SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table"); -SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT, - 0, 0, sysctl_kern_proc, "S,proc", "Return entire process table"); +SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT| + CTLFLAG_MPSAFE, 0, 0, sysctl_kern_proc, "S,proc", + "Return entire process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD, - sysctl_kern_proc, "Process table"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Return process table, no threads"); static SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, - CTLFLAG_RW | CTLFLAG_ANYBODY, + CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_args, "Process argument list"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD, - sysctl_kern_proc_pathname, "Process executable path"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_pathname, "Process executable path"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD, - sysctl_kern_proc_sv_name, "Process syscall vector name (ABI type)"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_sv_name, + "Process syscall vector name (ABI type)"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_GID | KERN_PROC_INC_THREAD), gid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PGRP | KERN_PROC_INC_THREAD), pgrp_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RGID | KERN_PROC_INC_THREAD), rgid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_SESSION | KERN_PROC_INC_THREAD), - sid_td, CTLFLAG_RD, sysctl_kern_proc, "Process table"); + sid_td, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_TTY | KERN_PROC_INC_THREAD), tty_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_UID | KERN_PROC_INC_THREAD), uid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RUID | KERN_PROC_INC_THREAD), ruid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PID | KERN_PROC_INC_THREAD), pid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PROC | KERN_PROC_INC_THREAD), proc_td, - CTLFLAG_RD, sysctl_kern_proc, "Return process table, no threads"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, + "Return process table, no threads"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_OVMMAP, ovmmap, CTLFLAG_RD, - sysctl_kern_proc_ovmmap, "Old Process vm map entries"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_OVMMAP, ovmmap, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_ovmmap, "Old Process vm map entries"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_VMMAP, vmmap, CTLFLAG_RD, - sysctl_kern_proc_vmmap, "Process vm map entries"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_VMMAP, vmmap, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_vmmap, "Process vm map entries"); #if defined(STACK) || defined(DDB) -static SYSCTL_NODE(_kern_proc, KERN_PROC_KSTACK, kstack, CTLFLAG_RD, - sysctl_kern_proc_kstack, "Process kernel stacks"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_KSTACK, kstack, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_kstack, "Process kernel stacks"); #endif Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 19:33:50 2009 (r189644) @@ -850,8 +850,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR return (error); } -SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY, 0, 0, - sysctl_sysctl_name2oid, "I", ""); +SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, + 0, 0, sysctl_sysctl_name2oid, "I", ""); static int sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS) @@ -873,7 +873,8 @@ sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS } -static SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD, sysctl_sysctl_oidfmt, ""); +static SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD|CTLFLAG_MPSAFE, + sysctl_sysctl_oidfmt, ""); static int sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS) @@ -1415,11 +1416,11 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif - - /* XXX: Handlers are not guaranteed to be Giant safe! */ - mtx_lock(&Giant); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_lock(&Giant); error = oid->oid_handler(oid, arg1, arg2, req); - mtx_unlock(&Giant); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_unlock(&Giant); return (error); } Modified: stable/7/sys/kern/vfs_cache.c ============================================================================== --- stable/7/sys/kern/vfs_cache.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/vfs_cache.c Tue Mar 10 19:33:50 2009 (r189644) @@ -163,8 +163,8 @@ static u_long numposhits; STATNODE(CTLFL static u_long numnegzaps; STATNODE(CTLFLAG_RD, numnegzaps, &numnegzaps); static u_long numneghits; STATNODE(CTLFLAG_RD, numneghits, &numneghits); -SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD, &nchstats, - sizeof(nchstats), "LU", "VFS cache effectiveness statistics"); +SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD | CTLFLAG_MPSAFE, + &nchstats, sizeof(nchstats), "LU", "VFS cache effectiveness statistics"); @@ -209,8 +209,9 @@ sysctl_debug_hashstat_rawnchash(SYSCTL_H } return (0); } -SYSCTL_PROC(_debug_hashstat, OID_AUTO, rawnchash, CTLTYPE_INT|CTLFLAG_RD, - 0, 0, sysctl_debug_hashstat_rawnchash, "S,int", "nchash chain lengths"); +SYSCTL_PROC(_debug_hashstat, OID_AUTO, rawnchash, CTLTYPE_INT|CTLFLAG_RD| + CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_rawnchash, "S,int", + "nchash chain lengths"); static int sysctl_debug_hashstat_nchash(SYSCTL_HANDLER_ARGS) @@ -255,8 +256,9 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND return (error); return (0); } -SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD, - 0, 0, sysctl_debug_hashstat_nchash, "I", "nchash chain lengths"); +SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD| + CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I", + "nchash chain lengths"); /* * cache_zap(): Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 19:33:50 2009 (r189644) @@ -84,6 +84,7 @@ struct ctlname { #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ #define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) /* @@ -244,54 +245,54 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e /* Oid for an int. If ptr is NULL, val is returned. */ #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "I", descr) #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "I", __DESCR(descr)) /* Oid for an unsigned int. If ptr is NULL, val is returned. */ #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IU", descr) #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IU", __DESCR(descr)) #define SYSCTL_XINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IX", descr) #define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IX", __DESCR(descr)) /* Oid for a long. The pointer must be non NULL. */ #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "L", descr) #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "L", __DESCR(descr)) /* Oid for an unsigned long. The pointer must be non NULL. */ #define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "LU", __DESCR(descr)) #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)) #define SYSCTL_XLONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "LX", __DESCR(descr)) #define SYSCTL_ADD_XLONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "LX", __DESCR(descr)) /* Oid for an opaque object. Specified by a pointer and a length. */ Modified: stable/7/sys/vm/vm_meter.c ============================================================================== --- stable/7/sys/vm/vm_meter.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/vm/vm_meter.c Tue Mar 10 19:33:50 2009 (r189644) @@ -89,8 +89,9 @@ sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS) #endif return SYSCTL_OUT(req, &averunnable, sizeof(averunnable)); } -SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD, - NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history"); +SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT | CTLFLAG_RD | + CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", + "Machine loadaverage history"); static int vmtotal(SYSCTL_HANDLER_ARGS) @@ -109,7 +110,6 @@ vmtotal(SYSCTL_HANDLER_ARGS) /* * Mark all objects as inactive. */ - GIANT_REQUIRED; mtx_lock(&vm_object_list_mtx); TAILQ_FOREACH(object, &vm_object_list, object_list) { if (!VM_OBJECT_TRYLOCK(object)) { @@ -275,7 +275,7 @@ vcnt(SYSCTL_HANDLER_ARGS) return (SYSCTL_OUT(req, &count, sizeof(int))); } -SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD, +SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, sizeof(struct vmtotal), vmtotal, "S,vmtotal", "System virtual memory statistics"); SYSCTL_NODE(_vm, OID_AUTO, stats, CTLFLAG_RW, 0, "VM meter stats"); @@ -285,103 +285,103 @@ static SYSCTL_NODE(_vm_stats, OID_AUTO, "VM meter vm stats"); SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW, 0, "VM meter misc stats"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_swtch, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_swtch, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swtch, 0, vcnt, "IU", "Context switches"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_trap, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_trap, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_trap, 0, vcnt, "IU", "Traps"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_syscall, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_syscall, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_syscall, 0, vcnt, "IU", "Syscalls"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intr, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intr, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_intr, 0, vcnt, "IU", "Hardware interrupts"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_soft, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_soft, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_soft, 0, vcnt, "IU", "Software interrupts"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vm_faults, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vm_faults, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vm_faults, 0, vcnt, "IU", "VM faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_faults, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_faults, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cow_faults, 0, vcnt, "IU", "COW faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_optim, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_optim, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cow_optim, 0, vcnt, "IU", "Optimized COW faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_zfod, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_zfod, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_zfod, 0, vcnt, "IU", "Zero fill"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_ozfod, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_ozfod, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_ozfod, 0, vcnt, "IU", "Optimized zero fill"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swapin, 0, vcnt, "IU", "Swapin operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swapout, 0, vcnt, "IU", "Swapout operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swappgsin, 0, vcnt, "IU", "Swapin pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swappgsout, 0, vcnt, "IU", "Swapout pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodein, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodein, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodein, 0, vcnt, "IU", "Vnodein operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodeout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodeout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodeout, 0, vcnt, "IU", "Vnodeout operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodepgsin, 0, vcnt, "IU", "Vnodein pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodepgsout, 0, vcnt, "IU", "Vnodeout pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_intrans, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_intrans, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_intrans, 0, vcnt, "IU", "In transit page blocking"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_reactivated, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_reactivated, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_reactivated, 0, vcnt, "IU", "Reactivated pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdwakeups, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdwakeups, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pdwakeups, 0, vcnt, "IU", "Pagedaemon wakeups"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pdpages, 0, vcnt, "IU", "Pagedaemon page scans"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tcached, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tcached, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_tcached, 0, vcnt, "IU", "Total pages cached"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_dfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_dfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_dfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_tfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_size, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_size, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_page_size, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_page_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_reserved, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_reserved, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_reserved, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_target, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_target, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_target, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_wire_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_wire_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_wire_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_active_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_active_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_active_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_target, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_target, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_inactive_target, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_inactive_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_max, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_max, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_max, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pageout_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pageout_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pageout_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_interrupt_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_interrupt_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_interrupt_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_forks, 0, vcnt, "IU", "Number of fork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vforks, 0, vcnt, "IU", "Number of vfork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_rforks, 0, vcnt, "IU", "Number of rfork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreads, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreads, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_kthreads, 0, vcnt, "IU", "Number of fork() calls by kernel"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_forkpages, 0, vcnt, "IU", "VM pages affected by fork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vforkpages, 0, vcnt, "IU", "VM pages affected by vfork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_rforkpages, 0, vcnt, "IU", "VM pages affected by rfork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreadpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreadpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_kthreadpages, 0, vcnt, "IU", "VM pages affected by fork() by kernel"); SYSCTL_INT(_vm_stats_misc, OID_AUTO, From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 00:58:23 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E1E71065672; Wed, 11 Mar 2009 00:58:23 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B2488FC19; Wed, 11 Mar 2009 00:58:23 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B0wMWR078637; Wed, 11 Mar 2009 00:58:22 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B0wMNM078636; Wed, 11 Mar 2009 00:58:22 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200903110058.n2B0wMNM078636@svn.freebsd.org> From: Andrew Thompson Date: Wed, 11 Mar 2009 00:58:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189658 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 00:58:23 -0000 Author: thompsa Date: Wed Mar 11 00:58:22 2009 New Revision: 189658 URL: http://svn.freebsd.org/changeset/base/189658 Log: MFC r188548 Check the exit flag at the start of the taskqueue loop rather than the end. It is possible to tear down the taskqueue before the thread has run and the taskqueue loop would sleep forever. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_taskqueue.c Modified: stable/7/sys/kern/subr_taskqueue.c ============================================================================== --- stable/7/sys/kern/subr_taskqueue.c Wed Mar 11 00:29:22 2009 (r189657) +++ stable/7/sys/kern/subr_taskqueue.c Wed Mar 11 00:58:22 2009 (r189658) @@ -397,10 +397,10 @@ taskqueue_thread_loop(void *arg) tqp = arg; tq = *tqp; TQ_LOCK(tq); - do { + while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) { taskqueue_run(tq); TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); - } while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0); + } /* rendezvous with thread that asked us to terminate */ tq->tq_pcount--; From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:03:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C054106564A; Wed, 11 Mar 2009 01:03:33 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F3668FC15; Wed, 11 Mar 2009 01:03:33 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B13Xo6078812; Wed, 11 Mar 2009 01:03:33 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B13WFM078809; Wed, 11 Mar 2009 01:03:32 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200903110103.n2B13WFM078809@svn.freebsd.org> From: Andrew Thompson Date: Wed, 11 Mar 2009 01:03:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189659 - in stable/7: share/man/man4 sys/dev/usb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:03:34 -0000 Author: thompsa Date: Wed Mar 11 01:03:32 2009 New Revision: 189659 URL: http://svn.freebsd.org/changeset/base/189659 Log: MFC r189360 Add Mobile Action MA-620 Infrared Adapter. Manually merged due to different codebase. Modified: stable/7/share/man/man4/uplcom.4 stable/7/sys/dev/usb/uplcom.c stable/7/sys/dev/usb/usbdevs Modified: stable/7/share/man/man4/uplcom.4 ============================================================================== --- stable/7/share/man/man4/uplcom.4 Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/share/man/man4/uplcom.4 Wed Mar 11 01:03:32 2009 (r189659) @@ -96,6 +96,8 @@ I/O DATA USB-RSAQ2 .It I/O DATA USB-RSAQ3 .It +Mobile Action MA-620 Infrared Adapter +.It PLANEX USB-RS232 URS-03 .It RATOC REX-USB60 Modified: stable/7/sys/dev/usb/uplcom.c ============================================================================== --- stable/7/sys/dev/usb/uplcom.c Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/sys/dev/usb/uplcom.c Wed Mar 11 01:03:32 2009 (r189659) @@ -272,6 +272,9 @@ static const struct uplcom_product { { USB_VENDOR_SITECOM, USB_PRODUCT_SITECOM_SERIAL, -1, TYPE_PL2303 }, /* Tripp-Lite U209-000-R */ { USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, -1, TYPE_PL2303X }, + /* Mobile Action MA-620 Infrared Adapter */ + { USB_VENDOR_MOBILEACTION, USB_PRODUCT_MOBILEACTION_MA620, -1, + TYPE_PL2303X }, { 0, 0 } }; Modified: stable/7/sys/dev/usb/usbdevs ============================================================================== --- stable/7/sys/dev/usb/usbdevs Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/sys/dev/usb/usbdevs Wed Mar 11 01:03:32 2009 (r189659) @@ -1716,6 +1716,9 @@ product MITSUMI CDRRW 0x0000 CD-R/RW Dr product MITSUMI BT_DONGLE 0x641f Bluetooth USB dongle product MITSUMI FDD 0x6901 USB FDD +/* Mobile Action products */ +product MOBILEACTION MA620 0x0620 MA-620 Infrared Adapter + /* Mobility products */ product MOBILITY EA 0x0204 Ethernet product MOBILITY EASIDOCK 0x0304 EasiDock Ethernet From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:47:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C2681065672; Wed, 11 Mar 2009 01:47:33 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 18C988FC20; Wed, 11 Mar 2009 01:47:33 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1lWLp079754; Wed, 11 Mar 2009 01:47:32 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1lWir079753; Wed, 11 Mar 2009 01:47:32 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110147.n2B1lWir079753@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:47:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189661 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:47:34 -0000 Author: rnoland Date: Wed Mar 11 01:47:32 2009 New Revision: 189661 URL: http://svn.freebsd.org/changeset/base/189661 Log: Merge r189045 Remove the PZERO priority from mtx_sleep. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:12:52 2009 (r189660) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:47:32 2009 (r189661) @@ -294,8 +294,8 @@ for ( ret = 0 ; !ret && !(condition) ; ) DRM_UNLOCK(); \ mtx_lock(&dev->irq_lock); \ if (!(condition)) \ - ret = -mtx_sleep(&(queue), &dev->irq_lock, \ - PZERO | PCATCH, "drmwtq", (timeout)); \ + ret = -mtx_sleep(&(queue), &dev->irq_lock, \ + PCATCH, "drmwtq", (timeout)); \ mtx_unlock(&dev->irq_lock); \ DRM_LOCK(); \ } From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:49:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C369E106566C; Wed, 11 Mar 2009 01:49:22 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7AB1A8FC0A; Wed, 11 Mar 2009 01:49:22 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1nMlM079838; Wed, 11 Mar 2009 01:49:22 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1nMn8079837; Wed, 11 Mar 2009 01:49:22 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110149.n2B1nMn8079837@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:49:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189662 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:49:23 -0000 Author: rnoland Date: Wed Mar 11 01:49:22 2009 New Revision: 189662 URL: http://svn.freebsd.org/changeset/base/189662 Log: Merge r189046 There is no reason to hold the lock here. When I was LOCK_PROFILING this was pretty high up and there is no reason for it. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:47:32 2009 (r189661) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:49:22 2009 (r189662) @@ -658,9 +658,7 @@ int drm_ioctl(struct cdev *kdev, u_long int is_driver_ioctl = 0; struct drm_file *file_priv; - DRM_LOCK(); retcode = devfs_get_cdevpriv((void **)&file_priv); - DRM_UNLOCK(); if (retcode != 0) { DRM_ERROR("can't find authenticator\n"); return EINVAL; From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:50:53 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65931106564A; Wed, 11 Mar 2009 01:50:53 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 512A88FC1E; Wed, 11 Mar 2009 01:50:53 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1orOe079923; Wed, 11 Mar 2009 01:50:53 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1orkh079920; Wed, 11 Mar 2009 01:50:53 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110150.n2B1orkh079920@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:50:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189663 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:50:54 -0000 Author: rnoland Date: Wed Mar 11 01:50:53 2009 New Revision: 189663 URL: http://svn.freebsd.org/changeset/base/189663 Log: Merge r189047 The vblank_swap ioctl was fundamentally race prone. Get rid of it. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:50:53 2009 (r189663) @@ -1087,7 +1087,6 @@ int i915_driver_load(struct drm_device * #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif - DRM_SPININIT(&dev_priv->swaps_lock, "swap"); DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); #ifdef __linux__ @@ -1117,7 +1116,6 @@ int i915_driver_unload(struct drm_device drm_rmmap(dev, dev_priv->mmio_map); - DRM_SPINUNINIT(&dev_priv->swaps_lock); DRM_SPINUNINIT(&dev_priv->user_irq_lock); #ifdef __linux__ Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 01:50:53 2009 (r189663) @@ -178,9 +178,6 @@ typedef struct drm_i915_private { struct drm_i915_validate_buffer *val_bufs; #endif - DRM_SPINTYPE swaps_lock; - drm_i915_vbl_swap_t vbl_swaps; - unsigned int swaps_pending; #if defined(I915_HAVE_BUFFER) /* DRI2 sarea */ struct drm_buffer_object *sarea_bo; Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 01:50:53 2009 (r189663) @@ -121,277 +121,6 @@ i915_pipe_enabled(struct drm_device *dev return 0; } -/** - * Emit a synchronous flip. - * - * This function must be called with the drawable spinlock held. - */ -static void -i915_dispatch_vsync_flip(struct drm_device *dev, struct drm_drawable_info *drw, - int plane) -{ - drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv; - u16 x1, y1, x2, y2; - int pf_planes = 1 << plane; - - DRM_SPINLOCK_ASSERT(&dev->drw_lock); - - /* If the window is visible on the other plane, we have to flip on that - * plane as well. - */ - if (plane == 1) { - x1 = sarea_priv->planeA_x; - y1 = sarea_priv->planeA_y; - x2 = x1 + sarea_priv->planeA_w; - y2 = y1 + sarea_priv->planeA_h; - } else { - x1 = sarea_priv->planeB_x; - y1 = sarea_priv->planeB_y; - x2 = x1 + sarea_priv->planeB_w; - y2 = y1 + sarea_priv->planeB_h; - } - - if (x2 > 0 && y2 > 0) { - int i, num_rects = drw->num_rects; - struct drm_clip_rect *rect = drw->rects; - - for (i = 0; i < num_rects; i++) - if (!(rect[i].x1 >= x2 || rect[i].y1 >= y2 || - rect[i].x2 <= x1 || rect[i].y2 <= y1)) { - pf_planes = 0x3; - - break; - } - } - - i915_dispatch_flip(dev, pf_planes, 1); -} - -/** - * Emit blits for scheduled buffer swaps. - * - * This function will be called with the HW lock held. - */ -static void i915_vblank_tasklet(struct drm_device *dev) -{ - drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - struct list_head *list, *tmp, hits, *hit; - int nhits, nrects, slice[2], upper[2], lower[2], i, num_pages; - unsigned counter[2]; - struct drm_drawable_info *drw; - drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv; - u32 cpp = dev_priv->cpp, offsets[3]; - u32 cmd = (cpp == 4) ? (XY_SRC_COPY_BLT_CMD | - XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB) - : XY_SRC_COPY_BLT_CMD; - u32 src_pitch = sarea_priv->pitch * cpp; - u32 dst_pitch = sarea_priv->pitch * cpp; - /* COPY rop (0xcc), map cpp to magic color depth constants */ - u32 ropcpp = (0xcc << 16) | ((cpp - 1) << 24); - RING_LOCALS; - - if (IS_I965G(dev) && sarea_priv->front_tiled) { - cmd |= XY_SRC_COPY_BLT_DST_TILED; - dst_pitch >>= 2; - } - if (IS_I965G(dev) && sarea_priv->back_tiled) { - cmd |= XY_SRC_COPY_BLT_SRC_TILED; - src_pitch >>= 2; - } - - counter[0] = drm_vblank_count(dev, 0); - counter[1] = drm_vblank_count(dev, 1); - - DRM_DEBUG("\n"); - - INIT_LIST_HEAD(&hits); - - nhits = nrects = 0; - - /* No irqsave/restore necessary. This tasklet may be run in an - * interrupt context or normal context, but we don't have to worry - * about getting interrupted by something acquiring the lock, because - * we are the interrupt context thing that acquires the lock. - */ - DRM_SPINLOCK(&dev_priv->swaps_lock); - - /* Find buffer swaps scheduled for this vertical blank */ - list_for_each_safe(list, tmp, &dev_priv->vbl_swaps.head) { - drm_i915_vbl_swap_t *vbl_swap = - list_entry(list, drm_i915_vbl_swap_t, head); - int pipe = i915_get_pipe(dev, vbl_swap->plane); - - if ((counter[pipe] - vbl_swap->sequence) > (1<<23)) - continue; - - list_del(list); - dev_priv->swaps_pending--; - drm_vblank_put(dev, pipe); - - DRM_SPINUNLOCK(&dev_priv->swaps_lock); - DRM_SPINLOCK(&dev->drw_lock); - - drw = drm_get_drawable_info(dev, vbl_swap->drw_id); - - if (!drw) { - DRM_SPINUNLOCK(&dev->drw_lock); - drm_free(vbl_swap, sizeof(*vbl_swap), DRM_MEM_DRIVER); - DRM_SPINLOCK(&dev_priv->swaps_lock); - continue; - } - - list_for_each(hit, &hits) { - drm_i915_vbl_swap_t *swap_cmp = - list_entry(hit, drm_i915_vbl_swap_t, head); - struct drm_drawable_info *drw_cmp = - drm_get_drawable_info(dev, swap_cmp->drw_id); - - if (drw_cmp && - drw_cmp->rects[0].y1 > drw->rects[0].y1) { - list_add_tail(list, hit); - break; - } - } - - DRM_SPINUNLOCK(&dev->drw_lock); - - /* List of hits was empty, or we reached the end of it */ - if (hit == &hits) - list_add_tail(list, hits.prev); - - nhits++; - - DRM_SPINLOCK(&dev_priv->swaps_lock); - } - - DRM_SPINUNLOCK(&dev_priv->swaps_lock); - - if (nhits == 0) { - return; - } - - i915_kernel_lost_context(dev); - - upper[0] = upper[1] = 0; - slice[0] = max(sarea_priv->planeA_h / nhits, 1); - slice[1] = max(sarea_priv->planeB_h / nhits, 1); - lower[0] = sarea_priv->planeA_y + slice[0]; - lower[1] = sarea_priv->planeB_y + slice[0]; - - offsets[0] = sarea_priv->front_offset; - offsets[1] = sarea_priv->back_offset; - offsets[2] = sarea_priv->third_offset; - num_pages = sarea_priv->third_handle ? 3 : 2; - - DRM_SPINLOCK(&dev->drw_lock); - - /* Emit blits for buffer swaps, partitioning both outputs into as many - * slices as there are buffer swaps scheduled in order to avoid tearing - * (based on the assumption that a single buffer swap would always - * complete before scanout starts). - */ - for (i = 0; i++ < nhits; - upper[0] = lower[0], lower[0] += slice[0], - upper[1] = lower[1], lower[1] += slice[1]) { - int init_drawrect = 1; - - if (i == nhits) - lower[0] = lower[1] = sarea_priv->height; - - list_for_each(hit, &hits) { - drm_i915_vbl_swap_t *swap_hit = - list_entry(hit, drm_i915_vbl_swap_t, head); - struct drm_clip_rect *rect; - int num_rects, plane, front, back; - unsigned short top, bottom; - - drw = drm_get_drawable_info(dev, swap_hit->drw_id); - - if (!drw) - continue; - - plane = swap_hit->plane; - - if (swap_hit->flip) { - i915_dispatch_vsync_flip(dev, drw, plane); - continue; - } - - if (init_drawrect) { - int width = sarea_priv->width; - int height = sarea_priv->height; - if (IS_I965G(dev)) { - BEGIN_LP_RING(4); - - OUT_RING(GFX_OP_DRAWRECT_INFO_I965); - OUT_RING(0); - OUT_RING(((width - 1) & 0xffff) | ((height - 1) << 16)); - OUT_RING(0); - - ADVANCE_LP_RING(); - } else { - BEGIN_LP_RING(6); - - OUT_RING(GFX_OP_DRAWRECT_INFO); - OUT_RING(0); - OUT_RING(0); - OUT_RING(((width - 1) & 0xffff) | ((height - 1) << 16)); - OUT_RING(0); - OUT_RING(0); - - ADVANCE_LP_RING(); - } - - sarea_priv->ctxOwner = DRM_KERNEL_CONTEXT; - - init_drawrect = 0; - } - - rect = drw->rects; - top = upper[plane]; - bottom = lower[plane]; - - front = (dev_priv->sarea_priv->pf_current_page >> - (2 * plane)) & 0x3; - back = (front + 1) % num_pages; - - for (num_rects = drw->num_rects; num_rects--; rect++) { - int y1 = max(rect->y1, top); - int y2 = min(rect->y2, bottom); - - if (y1 >= y2) - continue; - - BEGIN_LP_RING(8); - - OUT_RING(cmd); - OUT_RING(ropcpp | dst_pitch); - OUT_RING((y1 << 16) | rect->x1); - OUT_RING((y2 << 16) | rect->x2); - OUT_RING(offsets[front]); - OUT_RING((y1 << 16) | rect->x1); - OUT_RING(src_pitch); - OUT_RING(offsets[back]); - - ADVANCE_LP_RING(); - } - } - } - - DRM_SPINUNLOCK(&dev->drw_lock); - - list_for_each_safe(hit, tmp, &hits) { - drm_i915_vbl_swap_t *swap_hit = - list_entry(hit, drm_i915_vbl_swap_t, head); - - list_del(hit); - - drm_free(swap_hit, sizeof(*swap_hit), DRM_MEM_DRIVER); - } -} - u32 i915_get_vblank_counter(struct drm_device *dev, int plane) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -526,11 +255,6 @@ irqreturn_t i915_driver_irq_handler(DRM_ #endif } - if (vblank) { - if (dev_priv->swaps_pending > 0) - drm_locked_tasklet(dev, i915_vblank_tasklet); - } - return IRQ_HANDLED; } @@ -796,157 +520,22 @@ int i915_vblank_pipe_get(struct drm_devi int i915_vblank_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) { - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_vblank_swap_t *swap = data; - drm_i915_vbl_swap_t *vbl_swap; - unsigned int pipe, seqtype, curseq, plane; - unsigned long irqflags; - struct list_head *list; - int ret; - - if (!dev_priv) { - DRM_ERROR("%s called with no initialization\n", __func__); - return -EINVAL; - } - - if (!dev_priv->sarea_priv || dev_priv->sarea_priv->rotation) { - DRM_DEBUG("Rotation not supported\n"); - return -EINVAL; - } - - if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | - _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS | - _DRM_VBLANK_FLIP)) { - DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype); - return -EINVAL; - } - - plane = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; - pipe = i915_get_pipe(dev, plane); - - seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); - - if (!(dev_priv->vblank_pipe & (1 << pipe))) { - DRM_ERROR("Invalid pipe %d\n", pipe); - return -EINVAL; - } - - DRM_SPINLOCK_IRQSAVE(&dev->drw_lock, irqflags); - - /* It makes no sense to schedule a swap for a drawable that doesn't have - * valid information at this point. E.g. this could mean that the X - * server is too old to push drawable information to the DRM, in which - * case all such swaps would become ineffective. + /* The delayed swap mechanism was fundamentally racy, and has been + * removed. The model was that the client requested a delayed flip/swap + * from the kernel, then waited for vblank before continuing to perform + * rendering. The problem was that the kernel might wake the client + * up before it dispatched the vblank swap (since the lock has to be + * held while touching the ringbuffer), in which case the client would + * clear and start the next frame before the swap occurred, and + * flicker would occur in addition to likely missing the vblank. + * + * In the absence of this ioctl, userland falls back to a correct path + * of waiting for a vblank, then dispatching the swap on its own. + * Context switching to userland and back is plenty fast enough for + * meeting the requirements of vblank swapping. */ - if (!drm_get_drawable_info(dev, swap->drawable)) { - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable); - return -EINVAL; - } - - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - - /* - * We take the ref here and put it when the swap actually completes - * in the tasklet. - */ - ret = drm_vblank_get(dev, pipe); - if (ret) - return ret; - curseq = drm_vblank_count(dev, pipe); - - if (seqtype == _DRM_VBLANK_RELATIVE) - swap->sequence += curseq; - - if ((curseq - swap->sequence) <= (1<<23)) { - if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) { - swap->sequence = curseq + 1; - } else { - DRM_DEBUG("Missed target sequence\n"); - drm_vblank_put(dev, pipe); - return -EINVAL; - } - } - - if (swap->seqtype & _DRM_VBLANK_FLIP) { - swap->sequence--; - - if ((curseq - swap->sequence) <= (1<<23)) { - struct drm_drawable_info *drw; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - DRM_SPINLOCK_IRQSAVE(&dev->drw_lock, irqflags); - - drw = drm_get_drawable_info(dev, swap->drawable); - - if (!drw) { - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, - irqflags); - DRM_DEBUG("Invalid drawable ID %d\n", - swap->drawable); - drm_vblank_put(dev, pipe); - return -EINVAL; - } - - i915_dispatch_vsync_flip(dev, drw, plane); - - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - - drm_vblank_put(dev, pipe); - return 0; - } - } - - DRM_SPINLOCK_IRQSAVE(&dev_priv->swaps_lock, irqflags); - - list_for_each(list, &dev_priv->vbl_swaps.head) { - vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); - - if (vbl_swap->drw_id == swap->drawable && - vbl_swap->plane == plane && - vbl_swap->sequence == swap->sequence) { - vbl_swap->flip = (swap->seqtype & _DRM_VBLANK_FLIP); - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - DRM_DEBUG("Already scheduled\n"); - return 0; - } - } - - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - - if (dev_priv->swaps_pending >= 100) { - DRM_DEBUG("Too many swaps queued\n"); - drm_vblank_put(dev, pipe); - return -EBUSY; - } - - vbl_swap = drm_calloc(1, sizeof(*vbl_swap), DRM_MEM_DRIVER); - - if (!vbl_swap) { - DRM_ERROR("Failed to allocate memory to queue swap\n"); - drm_vblank_put(dev, pipe); - return -ENOMEM; - } - - DRM_DEBUG("\n"); - - vbl_swap->drw_id = swap->drawable; - vbl_swap->plane = plane; - vbl_swap->sequence = swap->sequence; - vbl_swap->flip = (swap->seqtype & _DRM_VBLANK_FLIP); - - if (vbl_swap->flip) - swap->sequence++; - - DRM_SPINLOCK_IRQSAVE(&dev_priv->swaps_lock, irqflags); - - list_add_tail(&vbl_swap->head, &dev_priv->vbl_swaps.head); - dev_priv->swaps_pending++; - - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - - return 0; + return -EINVAL; } /* drm_dma.h hooks @@ -965,9 +554,6 @@ int i915_driver_irq_postinstall(struct d drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; int ret, num_pipes = 2; - INIT_LIST_HEAD(&dev_priv->vbl_swaps.head); - dev_priv->swaps_pending = 0; - dev_priv->user_irq_refcount = 0; dev_priv->irq_mask_reg = ~0; From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:53:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64E3F1065672; Wed, 11 Mar 2009 01:53:22 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 512788FC17; Wed, 11 Mar 2009 01:53:22 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1rM4E080034; Wed, 11 Mar 2009 01:53:22 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1rLjQ080030; Wed, 11 Mar 2009 01:53:21 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110153.n2B1rLjQ080030@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:53:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189664 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:53:23 -0000 Author: rnoland Date: Wed Mar 11 01:53:21 2009 New Revision: 189664 URL: http://svn.freebsd.org/changeset/base/189664 Log: Merge 189048 The i915 driver was the only consumer of locked task support. Now that it doesn't use it anymore, get right of the taskqueue and locked task support. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c stable/7/sys/dev/drm/drm_lock.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:53:21 2009 (r189664) @@ -63,7 +63,6 @@ struct drm_file; #include #include #include -#include #include #include #include @@ -628,7 +627,6 @@ struct drm_device { struct mtx irq_lock; /* protects irq condition checks */ struct mtx dev_lock; /* protects everything else */ DRM_SPINTYPE drw_lock; - DRM_SPINTYPE tsk_lock; /* Usage Counters */ int open_count; /* Outstanding files open */ @@ -695,9 +693,6 @@ struct drm_device { struct unrhdr *drw_unrhdr; /* RB tree of drawable infos */ RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head; - - struct task locked_task; - void (*locked_task_call)(struct drm_device *dev); }; static __inline__ int drm_core_check_feature(struct drm_device *dev, @@ -918,8 +913,6 @@ int drm_control(struct drm_device *dev, struct drm_file *file_priv); int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv); -void drm_locked_tasklet(struct drm_device *dev, - void (*tasklet)(struct drm_device *dev)); /* AGP/GART support (drm_agpsupport.c) */ int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:53:21 2009 (r189664) @@ -193,7 +193,6 @@ int drm_attach(device_t nbdev, drm_pci_i mtx_init(&dev->irq_lock, "drmirq", NULL, MTX_DEF); mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF); mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF); - mtx_init(&dev->tsk_lock, "drmtsk", NULL, MTX_DEF); id_entry = drm_find_description(pci_get_vendor(dev->device), pci_get_device(dev->device), idlist); @@ -440,7 +439,6 @@ error: DRM_UNLOCK(); destroy_dev(dev->devnode); - mtx_destroy(&dev->tsk_lock); mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); @@ -503,14 +501,12 @@ static void drm_unload(struct drm_device if (pci_disable_busmaster(dev->device)) DRM_ERROR("Request to disable bus-master failed.\n"); - mtx_destroy(&dev->tsk_lock); mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); mtx_destroy(&dev->dev_lock); } - int drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_version *version = data; Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:53:21 2009 (r189664) @@ -36,8 +36,6 @@ __FBSDID("$FreeBSD$"); #include "dev/drm/drmP.h" #include "dev/drm/drm.h" -static void drm_locked_task(void *context, int pending __unused); - int drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -198,7 +196,6 @@ int drm_irq_install(struct drm_device *d dev->driver->irq_postinstall(dev); DRM_UNLOCK(); - TASK_INIT(&dev->locked_task, 0, drm_locked_task, dev); return 0; err: DRM_LOCK(); @@ -507,46 +504,3 @@ void drm_handle_vblank(struct drm_device drm_vbl_send_signals(dev, crtc); } -static void drm_locked_task(void *context, int pending __unused) -{ - struct drm_device *dev = context; - - DRM_SPINLOCK(&dev->tsk_lock); - - DRM_LOCK(); /* XXX drm_lock_take() should do it's own locking */ - if (dev->locked_task_call == NULL || - drm_lock_take(&dev->lock, DRM_KERNEL_CONTEXT) == 0) { - DRM_UNLOCK(); - DRM_SPINUNLOCK(&dev->tsk_lock); - return; - } - - dev->lock.file_priv = NULL; /* kernel owned */ - dev->lock.lock_time = jiffies; - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); - - DRM_UNLOCK(); - - dev->locked_task_call(dev); - - drm_lock_free(&dev->lock, DRM_KERNEL_CONTEXT); - - dev->locked_task_call = NULL; - - DRM_SPINUNLOCK(&dev->tsk_lock); -} - -void -drm_locked_tasklet(struct drm_device *dev, - void (*tasklet)(struct drm_device *dev)) -{ - DRM_SPINLOCK(&dev->tsk_lock); - if (dev->locked_task_call != NULL) { - DRM_SPINUNLOCK(&dev->tsk_lock); - return; - } - - dev->locked_task_call = tasklet; - DRM_SPINUNLOCK(&dev->tsk_lock); - taskqueue_enqueue(taskqueue_swi, &dev->locked_task); -} Modified: stable/7/sys/dev/drm/drm_lock.c ============================================================================== --- stable/7/sys/dev/drm/drm_lock.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_lock.c Wed Mar 11 01:53:21 2009 (r189664) @@ -115,13 +115,6 @@ int drm_unlock(struct drm_device *dev, v return EINVAL; } - DRM_SPINLOCK(&dev->tsk_lock); - if (dev->locked_task_call != NULL) { - dev->locked_task_call(dev); - dev->locked_task_call = NULL; - } - DRM_SPINUNLOCK(&dev->tsk_lock); - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); DRM_LOCK(); From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:54:41 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A24D81065670; Wed, 11 Mar 2009 01:54:41 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E10D8FC1C; Wed, 11 Mar 2009 01:54:41 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1sfoO080115; Wed, 11 Mar 2009 01:54:41 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1sfod080112; Wed, 11 Mar 2009 01:54:41 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110154.n2B1sfod080112@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:54:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189665 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:54:42 -0000 Author: rnoland Date: Wed Mar 11 01:54:41 2009 New Revision: 189665 URL: http://svn.freebsd.org/changeset/base/189665 Log: Merge r189049 This was part of a sync to the code that Intel is shipping in linux. - Remove the old TTM interface - Move register definitions to i915_reg.h - Overhaul the irq handler Added: stable/7/sys/dev/drm/i915_reg.h - copied unchanged from r189049, head/sys/dev/drm/i915_reg.h Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:53:21 2009 (r189664) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:54:41 2009 (r189665) @@ -655,6 +655,7 @@ struct drm_device { /* Context support */ int irq; /* Interrupt used by board */ int irq_enabled; /* True if the irq handler is enabled */ + int msi_enabled; /* MSI enabled */ int irqrid; /* Interrupt used by board */ struct resource *irqr; /* Resource for interrupt used by board */ void *irqh; /* Handle from bus_setup_intr */ Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:53:21 2009 (r189664) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:54:41 2009 (r189665) @@ -58,6 +58,9 @@ int i915_wait_ring(struct drm_device * d if (ring->space >= n) return 0; + if (dev_priv->sarea_priv) + dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; + if (ring->head != last_head) i = 0; @@ -72,77 +75,53 @@ int i915_wait_ring(struct drm_device * d return -EBUSY; } -int i915_init_hardware_status(struct drm_device *dev) +/** + * Sets up the hardware status page for devices that need a physical address + * in the register. + */ +static int i915_init_phys_hws(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; - drm_dma_handle_t *dmah; /* Program Hardware Status Page */ -#ifdef __FreeBSD__ DRM_UNLOCK(); -#endif - dmah = drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); -#ifdef __FreeBSD__ + dev_priv->status_page_dmah = + drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); DRM_LOCK(); -#endif - if (!dmah) { + if (!dev_priv->status_page_dmah) { DRM_ERROR("Can not allocate hardware status page\n"); return -ENOMEM; } - - dev_priv->status_page_dmah = dmah; - dev_priv->hw_status_page = dmah->vaddr; - dev_priv->dma_status_page = dmah->busaddr; + dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr; + dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr; memset(dev_priv->hw_status_page, 0, PAGE_SIZE); - I915_WRITE(0x02080, dev_priv->dma_status_page); + I915_WRITE(HWS_PGA, dev_priv->dma_status_page); DRM_DEBUG("Enabled hardware status page\n"); return 0; } -void i915_free_hardware_status(struct drm_device *dev) +/** + * Frees the hardware status page, whether it's a physical address or a virtual + * address set up by the X Server. + */ +static void i915_free_hws(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; if (dev_priv->status_page_dmah) { drm_pci_free(dev, dev_priv->status_page_dmah); dev_priv->status_page_dmah = NULL; - /* Need to rewrite hardware status page */ - I915_WRITE(0x02080, 0x1ffff000); } if (dev_priv->status_gfx_addr) { dev_priv->status_gfx_addr = 0; drm_core_ioremapfree(&dev_priv->hws_map, dev); - I915_WRITE(0x02080, 0x1ffff000); } -} -#if I915_RING_VALIDATE -/** - * Validate the cached ring tail value - * - * If the X server writes to the ring and DRM doesn't - * reload the head and tail pointers, it will end up writing - * data to the wrong place in the ring, causing havoc. - */ -void i915_ring_validate(struct drm_device *dev, const char *func, int line) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_ring_buffer_t *ring = &(dev_priv->ring); - u32 tail = I915_READ(PRB0_TAIL) & HEAD_ADDR; - u32 head = I915_READ(PRB0_HEAD) & HEAD_ADDR; - - if (tail != ring->tail) { - DRM_ERROR("%s:%d head sw %x, hw %x. tail sw %x hw %x\n", - func, line, - ring->head, head, ring->tail, tail); -#ifdef __linux__ - BUG_ON(1); -#endif - } + /* Need to rewrite hardware status page */ + I915_WRITE(HWS_PGA, 0x1ffff000); } -#endif void i915_kernel_lost_context(struct drm_device * dev) { @@ -154,6 +133,9 @@ void i915_kernel_lost_context(struct drm ring->space = ring->head - (ring->tail + 8); if (ring->space < 0) ring->space += ring->Size; + + if (ring->head == ring->tail && dev_priv->sarea_priv) + dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY; } static int i915_dma_cleanup(struct drm_device * dev) @@ -168,86 +150,22 @@ static int i915_dma_cleanup(struct drm_d if (dev_priv->ring.virtual_start) { drm_core_ioremapfree(&dev_priv->ring.map, dev); - dev_priv->ring.virtual_start = 0; - dev_priv->ring.map.handle = 0; + dev_priv->ring.virtual_start = NULL; + dev_priv->ring.map.handle = NULL; dev_priv->ring.map.size = 0; } + /* Clear the HWS virtual address at teardown */ if (I915_NEED_GFX_HWS(dev)) - i915_free_hardware_status(dev); + i915_free_hws(dev); return 0; } -#if defined(I915_HAVE_BUFFER) -#define DRI2_SAREA_BLOCK_TYPE(b) ((b) >> 16) -#define DRI2_SAREA_BLOCK_SIZE(b) ((b) & 0xffff) -#define DRI2_SAREA_BLOCK_NEXT(p) \ - ((void *) ((unsigned char *) (p) + \ - DRI2_SAREA_BLOCK_SIZE(*(unsigned int *) p))) - -#define DRI2_SAREA_BLOCK_END 0x0000 -#define DRI2_SAREA_BLOCK_LOCK 0x0001 -#define DRI2_SAREA_BLOCK_EVENT_BUFFER 0x0002 - -static int -setup_dri2_sarea(struct drm_device * dev, - struct drm_file *file_priv, - drm_i915_init_t * init) +static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init) { drm_i915_private_t *dev_priv = dev->dev_private; - int ret; - unsigned int *p, *end, *next; - - mutex_lock(&dev->struct_mutex); - dev_priv->sarea_bo = - drm_lookup_buffer_object(file_priv, - init->sarea_handle, 1); - mutex_unlock(&dev->struct_mutex); - - if (!dev_priv->sarea_bo) { - DRM_ERROR("did not find sarea bo\n"); - return -EINVAL; - } - - ret = drm_bo_kmap(dev_priv->sarea_bo, 0, - dev_priv->sarea_bo->num_pages, - &dev_priv->sarea_kmap); - if (ret) { - DRM_ERROR("could not map sarea bo\n"); - return ret; - } - - p = dev_priv->sarea_kmap.virtual; - end = (void *) p + (dev_priv->sarea_bo->num_pages << PAGE_SHIFT); - while (p < end && DRI2_SAREA_BLOCK_TYPE(*p) != DRI2_SAREA_BLOCK_END) { - switch (DRI2_SAREA_BLOCK_TYPE(*p)) { - case DRI2_SAREA_BLOCK_LOCK: - dev->lock.hw_lock = (void *) (p + 1); - dev->sigdata.lock = dev->lock.hw_lock; - break; - } - next = DRI2_SAREA_BLOCK_NEXT(p); - if (next <= p || end < next) { - DRM_ERROR("malformed dri2 sarea: next is %p should be within %p-%p\n", - next, p, end); - return -EINVAL; - } - p = next; - } - - return 0; -} -#endif -static int i915_initialize(struct drm_device * dev, - struct drm_file *file_priv, - drm_i915_init_t * init) -{ - drm_i915_private_t *dev_priv = dev->dev_private; -#if defined(I915_HAVE_BUFFER) - int ret; -#endif dev_priv->sarea = drm_getsarea(dev); if (!dev_priv->sarea) { DRM_ERROR("can not find sarea!\n"); @@ -255,20 +173,17 @@ static int i915_initialize(struct drm_de return -EINVAL; } -#ifdef I915_HAVE_BUFFER - dev_priv->max_validate_buffers = I915_MAX_VALIDATE_BUFFERS; -#endif - - if (init->sarea_priv_offset) - dev_priv->sarea_priv = (drm_i915_sarea_t *) - ((u8 *) dev_priv->sarea->handle + - init->sarea_priv_offset); - else { - /* No sarea_priv for you! */ - dev_priv->sarea_priv = NULL; - } + dev_priv->sarea_priv = (drm_i915_sarea_t *) + ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); if (init->ring_size != 0) { + if (dev_priv->ring.ring_obj != NULL) { + i915_dma_cleanup(dev); + DRM_ERROR("Client tried to initialize ringbuffer in " + "GEM mode\n"); + return -EINVAL; + } + dev_priv->ring.Size = init->ring_size; dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; @@ -286,41 +201,20 @@ static int i915_initialize(struct drm_de " ring buffer\n"); return -ENOMEM; } - - dev_priv->ring.virtual_start = dev_priv->ring.map.handle; } - dev_priv->cpp = init->cpp; - - if (dev_priv->sarea_priv) - dev_priv->sarea_priv->pf_current_page = 0; + dev_priv->ring.virtual_start = dev_priv->ring.map.handle; - /* We are using separate values as placeholders for mechanisms for - * private backbuffer/depthbuffer usage. - */ + dev_priv->cpp = init->cpp; + dev_priv->back_offset = init->back_offset; + dev_priv->front_offset = init->front_offset; + dev_priv->current_page = 0; + dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; /* Allow hardware batchbuffers unless told otherwise. */ dev_priv->allow_batchbuffer = 1; - /* Enable vblank on pipe A for older X servers - */ - dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A; - -#ifdef I915_HAVE_BUFFER - mutex_init(&dev_priv->cmdbuf_mutex); -#endif -#if defined(I915_HAVE_BUFFER) - if (init->func == I915_INIT_DMA2) { - ret = setup_dri2_sarea(dev, file_priv, init); - if (ret) { - i915_dma_cleanup(dev); - DRM_ERROR("could not set up dri2 sarea\n"); - return ret; - } - } -#endif - return 0; } @@ -349,9 +243,9 @@ static int i915_dma_resume(struct drm_de DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); if (dev_priv->status_gfx_addr != 0) - I915_WRITE(0x02080, dev_priv->status_gfx_addr); + I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr); else - I915_WRITE(0x02080, dev_priv->dma_status_page); + I915_WRITE(HWS_PGA, dev_priv->dma_status_page); DRM_DEBUG("Enabled hardware status page\n"); return 0; @@ -365,8 +259,7 @@ static int i915_dma_init(struct drm_devi switch (init->func) { case I915_INIT_DMA: - case I915_INIT_DMA2: - retcode = i915_initialize(dev, file_priv, init); + retcode = i915_initialize(dev, init); break; case I915_CLEANUP_DMA: retcode = i915_dma_cleanup(dev); @@ -541,55 +434,28 @@ int i915_emit_box(struct drm_device * de * emit. For now, do it in both places: */ -void i915_emit_breadcrumb(struct drm_device *dev) +static void i915_emit_breadcrumb(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; RING_LOCALS; - if (++dev_priv->counter > BREADCRUMB_MASK) { - dev_priv->counter = 1; - DRM_DEBUG("Breadcrumb counter wrapped around\n"); - } - + dev_priv->counter++; + if (dev_priv->counter > 0x7FFFFFFFUL) + dev_priv->counter = 0; if (dev_priv->sarea_priv) dev_priv->sarea_priv->last_enqueue = dev_priv->counter; BEGIN_LP_RING(4); OUT_RING(MI_STORE_DWORD_INDEX); - OUT_RING(5 << MI_STORE_DWORD_INDEX_SHIFT); + OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); OUT_RING(dev_priv->counter); OUT_RING(0); ADVANCE_LP_RING(); } - -int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - uint32_t flush_cmd = MI_FLUSH; - RING_LOCALS; - - flush_cmd |= flush; - - i915_kernel_lost_context(dev); - - BEGIN_LP_RING(4); - OUT_RING(flush_cmd); - OUT_RING(0); - OUT_RING(0); - OUT_RING(0); - ADVANCE_LP_RING(); - - return 0; -} - - static int i915_dispatch_cmdbuffer(struct drm_device * dev, drm_i915_cmdbuffer_t * cmd) { -#ifdef I915_HAVE_FENCE - drm_i915_private_t *dev_priv = dev->dev_private; -#endif int nbox = cmd->num_cliprects; int i = 0, count, ret; @@ -616,15 +482,11 @@ static int i915_dispatch_cmdbuffer(struc } i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely((dev_priv->counter & 0xFF) == 0)) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif return 0; } -int i915_dispatch_batchbuffer(struct drm_device * dev, - drm_i915_batchbuffer_t * batch) +static int i915_dispatch_batchbuffer(struct drm_device * dev, + drm_i915_batchbuffer_t * batch) { drm_i915_private_t *dev_priv = dev->dev_private; struct drm_clip_rect __user *boxes = batch->cliprects; @@ -649,14 +511,7 @@ int i915_dispatch_batchbuffer(struct drm return ret; } - if (IS_I830(dev) || IS_845G(dev)) { - BEGIN_LP_RING(4); - OUT_RING(MI_BATCH_BUFFER); - OUT_RING(batch->start | MI_BATCH_NON_SECURE); - OUT_RING(batch->start + batch->used - 4); - OUT_RING(0); - ADVANCE_LP_RING(); - } else { + if (!IS_I830(dev) && !IS_845G(dev)) { BEGIN_LP_RING(2); if (IS_I965G(dev)) { OUT_RING(MI_BATCH_BUFFER_START | (2 << 6) | MI_BATCH_NON_SECURE_I965); @@ -666,115 +521,90 @@ int i915_dispatch_batchbuffer(struct drm OUT_RING(batch->start | MI_BATCH_NON_SECURE); } ADVANCE_LP_RING(); + } else { + BEGIN_LP_RING(4); + OUT_RING(MI_BATCH_BUFFER); + OUT_RING(batch->start | MI_BATCH_NON_SECURE); + OUT_RING(batch->start + batch->used - 4); + OUT_RING(0); + ADVANCE_LP_RING(); } } i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely((dev_priv->counter & 0xFF) == 0)) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif + return 0; } -static void i915_do_dispatch_flip(struct drm_device * dev, int plane, int sync) +static int i915_dispatch_flip(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; - u32 num_pages, current_page, next_page, dspbase; - int shift = 2 * plane, x, y; RING_LOCALS; - /* Calculate display base offset */ - num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2; - current_page = (dev_priv->sarea_priv->pf_current_page >> shift) & 0x3; - next_page = (current_page + 1) % num_pages; + if (!dev_priv->sarea_priv) + return -EINVAL; - switch (next_page) { - default: - case 0: - dspbase = dev_priv->sarea_priv->front_offset; - break; - case 1: - dspbase = dev_priv->sarea_priv->back_offset; - break; - case 2: - dspbase = dev_priv->sarea_priv->third_offset; - break; - } + DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", + __func__, + dev_priv->current_page, + dev_priv->sarea_priv->pf_current_page); + + i915_kernel_lost_context(dev); - if (plane == 0) { - x = dev_priv->sarea_priv->planeA_x; - y = dev_priv->sarea_priv->planeA_y; + BEGIN_LP_RING(2); + OUT_RING(MI_FLUSH | MI_READ_FLUSH); + OUT_RING(0); + ADVANCE_LP_RING(); + + BEGIN_LP_RING(6); + OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | ASYNC_FLIP); + OUT_RING(0); + if (dev_priv->current_page == 0) { + OUT_RING(dev_priv->back_offset); + dev_priv->current_page = 1; } else { - x = dev_priv->sarea_priv->planeB_x; - y = dev_priv->sarea_priv->planeB_y; + OUT_RING(dev_priv->front_offset); + dev_priv->current_page = 0; } + OUT_RING(0); + ADVANCE_LP_RING(); - dspbase += (y * dev_priv->sarea_priv->pitch + x) * dev_priv->cpp; + BEGIN_LP_RING(2); + OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP); + OUT_RING(0); + ADVANCE_LP_RING(); - DRM_DEBUG("plane=%d current_page=%d dspbase=0x%x\n", plane, current_page, - dspbase); + dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; BEGIN_LP_RING(4); - OUT_RING(sync ? 0 : - (MI_WAIT_FOR_EVENT | (plane ? MI_WAIT_FOR_PLANE_B_FLIP : - MI_WAIT_FOR_PLANE_A_FLIP))); - OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | (sync ? 0 : ASYNC_FLIP) | - (plane ? DISPLAY_PLANE_B : DISPLAY_PLANE_A)); - OUT_RING(dev_priv->sarea_priv->pitch * dev_priv->cpp); - OUT_RING(dspbase); + OUT_RING(MI_STORE_DWORD_INDEX); + OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); + OUT_RING(dev_priv->counter); + OUT_RING(0); ADVANCE_LP_RING(); - dev_priv->sarea_priv->pf_current_page &= ~(0x3 << shift); - dev_priv->sarea_priv->pf_current_page |= next_page << shift; -} - -void i915_dispatch_flip(struct drm_device * dev, int planes, int sync) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - int i; - - DRM_DEBUG("planes=0x%x pfCurrentPage=%d\n", - planes, dev_priv->sarea_priv->pf_current_page); - - i915_emit_mi_flush(dev, MI_READ_FLUSH | MI_EXE_FLUSH); - - for (i = 0; i < 2; i++) - if (planes & (1 << i)) - i915_do_dispatch_flip(dev, i, sync); - - i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely(!sync && ((dev_priv->counter & 0xFF) == 0))) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif + dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; + return 0; } -int i915_quiescent(struct drm_device *dev) +static int i915_quiescent(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; - int ret; i915_kernel_lost_context(dev); - ret = i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); - if (ret) - { - i915_kernel_lost_context (dev); - DRM_ERROR ("not quiescent head %08x tail %08x space %08x\n", - dev_priv->ring.head, - dev_priv->ring.tail, - dev_priv->ring.space); - } - return ret; + return i915_wait_ring(dev, dev_priv->ring.Size - 8, __func__); } static int i915_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { + int ret; - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); - return i915_quiescent(dev); + ret = i915_quiescent(dev); + + return ret; } static int i915_batchbuffer(struct drm_device *dev, void *data, @@ -784,6 +614,7 @@ static int i915_batchbuffer(struct drm_d drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) dev_priv->sarea_priv; drm_i915_batchbuffer_t *batch = data; + size_t cliplen; int ret; if (!dev_priv->allow_batchbuffer) { @@ -794,16 +625,35 @@ static int i915_batchbuffer(struct drm_d DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", batch->start, batch->used, batch->num_cliprects); - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); + DRM_UNLOCK(); + cliplen = batch->num_cliprects * sizeof(struct drm_clip_rect); if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects, - batch->num_cliprects * - sizeof(struct drm_clip_rect))) + cliplen)) { + DRM_LOCK(); return -EFAULT; + } + if (batch->num_cliprects) { + ret = vslock(batch->cliprects, cliplen); + if (ret) { + DRM_ERROR("Fault wiring cliprects\n"); + DRM_LOCK(); + return -EFAULT; + } + } + DRM_LOCK(); ret = i915_dispatch_batchbuffer(dev, batch); - sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); + if (sarea_priv) + sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); + + DRM_UNLOCK(); + if (batch->num_cliprects) + vsunlock(batch->cliprects, cliplen); + DRM_LOCK(); + return ret; } @@ -814,80 +664,70 @@ static int i915_cmdbuffer(struct drm_dev drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) dev_priv->sarea_priv; drm_i915_cmdbuffer_t *cmdbuf = data; + size_t cliplen; int ret; DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects); - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); - if (cmdbuf->num_cliprects && - DRM_VERIFYAREA_READ(cmdbuf->cliprects, - cmdbuf->num_cliprects * - sizeof(struct drm_clip_rect))) { + DRM_UNLOCK(); + cliplen = cmdbuf->num_cliprects * sizeof(struct drm_clip_rect); + if (cmdbuf->num_cliprects && DRM_VERIFYAREA_READ(cmdbuf->cliprects, + cliplen)) { DRM_ERROR("Fault accessing cliprects\n"); + DRM_LOCK(); return -EFAULT; } + if (cmdbuf->num_cliprects) { + ret = vslock(cmdbuf->cliprects, cliplen); + if (ret) { + DRM_ERROR("Fault wiring cliprects\n"); + DRM_LOCK(); + return -EFAULT; + } + ret = vslock(cmdbuf->buf, cmdbuf->sz); + if (ret) { + vsunlock(cmdbuf->cliprects, cliplen); + DRM_ERROR("Fault wiring cmds\n"); + DRM_LOCK(); + return -EFAULT; + } + } + DRM_LOCK(); ret = i915_dispatch_cmdbuffer(dev, cmdbuf); + DRM_UNLOCK(); + if (cmdbuf->num_cliprects) { + vsunlock(cmdbuf->buf, cmdbuf->sz); + vsunlock(cmdbuf->cliprects, cliplen); + } + DRM_LOCK(); if (ret) { DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); return ret; } - sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); - return 0; -} - -#if defined(DRM_DEBUG_CODE) -#define DRM_DEBUG_RELOCATION (drm_debug != 0) -#else -#define DRM_DEBUG_RELOCATION 0 -#endif - -static int i915_do_cleanup_pageflip(struct drm_device * dev) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - int i, planes, num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2; - - DRM_DEBUG("\n"); - - for (i = 0, planes = 0; i < 2; i++) - if (dev_priv->sarea_priv->pf_current_page & (0x3 << (2 * i))) { - dev_priv->sarea_priv->pf_current_page = - (dev_priv->sarea_priv->pf_current_page & - ~(0x3 << (2 * i))) | ((num_pages - 1) << (2 * i)); - - planes |= 1 << i; - } - - if (planes) - i915_dispatch_flip(dev, planes, 0); - + if (sarea_priv) + sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); return 0; } -static int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *file_priv) +static int i915_flip_bufs(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - drm_i915_flip_t *param = data; + int ret; - DRM_DEBUG("\n"); + DRM_DEBUG("%s\n", __func__); LOCK_TEST_WITH_RETURN(dev, file_priv); - /* This is really planes */ - if (param->pipes & ~0x3) { - DRM_ERROR("Invalid planes 0x%x, only <= 0x3 is valid\n", - param->pipes); - return -EINVAL; - } - - i915_dispatch_flip(dev, param->pipes, 0); + ret = i915_dispatch_flip(dev); - return 0; + return ret; } - static int i915_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -958,63 +798,6 @@ static int i915_setparam(struct drm_devi return 0; } -drm_i915_mmio_entry_t mmio_table[] = { - [MMIO_REGS_PS_DEPTH_COUNT] = { - I915_MMIO_MAY_READ|I915_MMIO_MAY_WRITE, - 0x2350, - 8 - } -}; - -static int mmio_table_size = sizeof(mmio_table)/sizeof(drm_i915_mmio_entry_t); - -static int i915_mmio(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - uint32_t buf[8]; - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_mmio_entry_t *e; - drm_i915_mmio_t *mmio = data; - void __iomem *base; - int i; - - if (!dev_priv) { - DRM_ERROR("called with no initialization\n"); - return -EINVAL; - } - - if (mmio->reg >= mmio_table_size) - return -EINVAL; - - e = &mmio_table[mmio->reg]; - base = (u8 *) dev_priv->mmio_map->handle + e->offset; - - switch (mmio->read_write) { - case I915_MMIO_READ: - if (!(e->flag & I915_MMIO_MAY_READ)) - return -EINVAL; - for (i = 0; i < e->size / 4; i++) - buf[i] = I915_READ(e->offset + i * 4); - if (DRM_COPY_TO_USER(mmio->data, buf, e->size)) { - DRM_ERROR("DRM_COPY_TO_USER failed\n"); - return -EFAULT; - } - break; - - case I915_MMIO_WRITE: - if (!(e->flag & I915_MMIO_MAY_WRITE)) - return -EINVAL; - if (DRM_COPY_FROM_USER(buf, mmio->data, e->size)) { - DRM_ERROR("DRM_COPY_TO_USER failed\n"); - return -EFAULT; - } - for (i = 0; i < e->size / 4; i++) - I915_WRITE(e->offset + i * 4, buf[i]); - break; - } - return 0; -} - static int i915_set_status_page(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -1028,6 +811,7 @@ static int i915_set_status_page(struct d DRM_ERROR("called with no initialization\n"); return -EINVAL; } + DRM_DEBUG("set status page addr 0x%08x\n", (u32)hws->addr); dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); @@ -1050,7 +834,7 @@ static int i915_set_status_page(struct d memset(dev_priv->hw_status_page, 0, PAGE_SIZE); I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr); - DRM_DEBUG("load hws 0x2080 with gfx mem 0x%x\n", + DRM_DEBUG("load hws HWS_PGA with gfx mem 0x%x\n", dev_priv->status_gfx_addr); DRM_DEBUG("load hws at %p\n", dev_priv->hw_status_page); return 0; @@ -1058,7 +842,7 @@ static int i915_set_status_page(struct d int i915_driver_load(struct drm_device *dev, unsigned long flags) { - struct drm_i915_private *dev_priv; + struct drm_i915_private *dev_priv = dev->dev_private; unsigned long base, size; int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1; @@ -1083,27 +867,34 @@ int i915_driver_load(struct drm_device * size = drm_get_resource_len(dev, mmio_bar); ret = drm_addmap(dev, base, size, _DRM_REGISTERS, - _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); + _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif - DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); - -#ifdef __linux__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) - intel_init_chipset_flush_compat(dev); -#endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) - intel_opregion_init(dev); -#endif -#endif - /* Init HWS */ if (!I915_NEED_GFX_HWS(dev)) { - ret = i915_init_hardware_status(dev); - if(ret) + ret = i915_init_phys_hws(dev); + if (ret != 0) return ret; } +#ifdef __linux__ + /* On the 945G/GM, the chipset reports the MSI capability on the + * integrated graphics even though the support isn't actually there + * according to the published specs. It doesn't appear to function + * correctly in testing on 945G. + * This may be a side effect of MSI having been made available for PEG + * and the registers being closely associated. + * + * According to chipset errata, on the 965GM, MSI interrupts may + * be lost or delayed + */ + if (!IS_I945G(dev) && !IS_I945GM(dev) && !IS_I965GM(dev)) + if (pci_enable_msi(dev->pdev)) + DRM_ERROR("failed to enable MSI\n"); + + intel_opregion_init(dev); +#endif + DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); return ret; } @@ -1112,71 +903,20 @@ int i915_driver_unload(struct drm_device { struct drm_i915_private *dev_priv = dev->dev_private; - i915_free_hardware_status(dev); - - drm_rmmap(dev, dev_priv->mmio_map); - - DRM_SPINUNINIT(&dev_priv->user_irq_lock); + i915_free_hws(dev); + drm_rmmap(dev, dev_priv->mmio_map); #ifdef __linux__ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) intel_opregion_free(dev); #endif -#endif + DRM_SPINUNINIT(&dev_priv->user_irq_lock); drm_free(dev->dev_private, sizeof(drm_i915_private_t), DRM_MEM_DRIVER); - dev->dev_private = NULL; -#ifdef __linux__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) - intel_fini_chipset_flush_compat(dev); -#endif -#endif return 0; } -void i915_driver_lastclose(struct drm_device * dev) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - - /* agp off can use this to get called before dev_priv */ - if (!dev_priv) - return; - -#ifdef I915_HAVE_BUFFER - if (dev_priv->val_bufs) { - vfree(dev_priv->val_bufs); - dev_priv->val_bufs = NULL; - } -#endif -#ifdef I915_HAVE_GEM - i915_gem_lastclose(dev); -#endif - if (drm_getsarea(dev) && dev_priv->sarea_priv) - i915_do_cleanup_pageflip(dev); - if (dev_priv->sarea_priv) - dev_priv->sarea_priv = NULL; - if (dev_priv->agp_heap) - i915_mem_takedown(&(dev_priv->agp_heap)); -#if defined(I915_HAVE_BUFFER) - if (dev_priv->sarea_kmap.virtual) { - drm_bo_kunmap(&dev_priv->sarea_kmap); - dev_priv->sarea_kmap.virtual = NULL; - dev->lock.hw_lock = NULL; - dev->sigdata.lock = NULL; - } - - if (dev_priv->sarea_bo) { - mutex_lock(&dev->struct_mutex); - drm_bo_usage_deref_locked(&dev_priv->sarea_bo); - mutex_unlock(&dev->struct_mutex); - dev_priv->sarea_bo = NULL; - } -#endif - i915_dma_cleanup(dev); -} - int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) { struct drm_i915_file_private *i915_file_priv; @@ -1196,6 +936,21 @@ int i915_driver_open(struct drm_device * return 0; } +void i915_driver_lastclose(struct drm_device * dev) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + + if (!dev_priv) + return; +#ifdef I915_HAVE_GEM + i915_gem_lastclose(dev); +#endif + if (dev_priv->agp_heap) + i915_mem_takedown(&(dev_priv->agp_heap)); + + i915_dma_cleanup(dev); +} + void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = dev->dev_private; @@ -1226,20 +981,16 @@ struct drm_ioctl_desc i915_ioctls[] = { DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), -#ifdef I915_HAVE_BUFFER - DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH), -#endif #ifdef I915_HAVE_GEM - DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH), *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:56:17 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 611E9106566B; Wed, 11 Mar 2009 01:56:17 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D3C38FC12; Wed, 11 Mar 2009 01:56:17 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1uHs9080235; Wed, 11 Mar 2009 01:56:17 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1uHQe080234; Wed, 11 Mar 2009 01:56:17 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110156.n2B1uHQe080234@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:56:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189666 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:56:18 -0000 Author: rnoland Date: Wed Mar 11 01:56:17 2009 New Revision: 189666 URL: http://svn.freebsd.org/changeset/base/189666 Log: Merge r189050 Add some vblank related debugging and replace the DRM_WAIT_ON macro with a localized version. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_irq.c Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:54:41 2009 (r189665) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:56:17 2009 (r189666) @@ -301,6 +301,7 @@ int drm_vblank_get(struct drm_device *de DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags); /* Going from 0->1 means we have to enable interrupts again */ atomic_add_acq_int(&dev->vblank[crtc].refcount, 1); + DRM_DEBUG("vblank refcount = %d\n", dev->vblank[crtc].refcount); if (dev->vblank[crtc].refcount == 1 && !dev->vblank[crtc].enabled) { ret = dev->driver->enable_vblank(dev, crtc); @@ -323,6 +324,7 @@ void drm_vblank_put(struct drm_device *d DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags); /* Last user schedules interrupt disable */ atomic_subtract_acq_int(&dev->vblank[crtc].refcount, 1); + DRM_DEBUG("vblank refcount = %d\n", dev->vblank[crtc].refcount); if (dev->vblank[crtc].refcount == 0) callout_reset(&dev->vblank_disable_timer, 5 * DRM_HZ, (timeout_t *)vblank_disable_fn, (void *)dev); @@ -385,8 +387,8 @@ out: int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv) { union drm_wait_vblank *vblwait = data; + unsigned int flags, seq, crtc; int ret = 0; - int flags, seq, crtc; if (!dev->irq_enabled) return EINVAL; @@ -406,8 +408,10 @@ int drm_wait_vblank(struct drm_device *d return EINVAL; ret = drm_vblank_get(dev, crtc); - if (ret) + if (ret) { + DRM_ERROR("failed to acquire vblank counter, %d\n", ret); return ret; + } seq = drm_vblank_count(dev, crtc); switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) { @@ -446,14 +450,20 @@ int drm_wait_vblank(struct drm_device *d #endif ret = EINVAL; } else { - DRM_LOCK(); - /* shared code returns -errno */ - - DRM_WAIT_ON(ret, dev->vblank[crtc].queue, 3 * DRM_HZ, - ((drm_vblank_count(dev, crtc) - - vblwait->request.sequence) <= (1 << 23))); - DRM_UNLOCK(); + DRM_DEBUG("waiting on vblank count %d, crtc %d\n", + vblwait->request.sequence, crtc); + for ( ret = 0 ; !ret && !((drm_vblank_count(dev, crtc) - + vblwait->request.sequence) <= (1 << 23)) ; ) { + mtx_lock(&dev->irq_lock); + if (!((drm_vblank_count(dev, crtc) - + vblwait->request.sequence) <= (1 << 23))) + ret = mtx_sleep(&dev->vblank[crtc].queue, + &dev->irq_lock, PCATCH, "vblwtq", + 3 * DRM_HZ); + mtx_unlock(&dev->irq_lock); + } + DRM_DEBUG("return = %d\n", ret); if (ret != EINTR) { struct timeval now; @@ -461,6 +471,10 @@ int drm_wait_vblank(struct drm_device *d vblwait->reply.tval_sec = now.tv_sec; vblwait->reply.tval_usec = now.tv_usec; vblwait->reply.sequence = drm_vblank_count(dev, crtc); + DRM_DEBUG("returning %d to client\n", + vblwait->reply.sequence); + } else { + DRM_DEBUG("vblank wait interrupted by signal\n"); } } From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:57:20 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB04C106566B; Wed, 11 Mar 2009 01:57:20 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C841E8FC0A; Wed, 11 Mar 2009 01:57:20 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1vKOb080304; Wed, 11 Mar 2009 01:57:20 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1vKH8080303; Wed, 11 Mar 2009 01:57:20 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110157.n2B1vKH8080303@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:57: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: r189667 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:57:21 -0000 Author: rnoland Date: Wed Mar 11 01:57:20 2009 New Revision: 189667 URL: http://svn.freebsd.org/changeset/base/189667 Log: Merge r189051 Prepare the radeon driver for MSI support. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/radeon_irq.c Modified: stable/7/sys/dev/drm/radeon_irq.c ============================================================================== --- stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 01:56:17 2009 (r189666) +++ stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 01:57:20 2009 (r189667) @@ -192,6 +192,7 @@ irqreturn_t radeon_driver_irq_handler(DR (drm_radeon_private_t *) dev->dev_private; u32 stat; u32 r500_disp_int; + u32 tmp; /* Only consider the bits we're interested in - others could be used * outside the DRM @@ -218,6 +219,33 @@ irqreturn_t radeon_driver_irq_handler(DR if (stat & RADEON_CRTC2_VBLANK_STAT) drm_handle_vblank(dev, 1); } + if (dev->msi_enabled) { + switch(dev_priv->flags & RADEON_FAMILY_MASK) { + case CHIP_RS400: + case CHIP_RS480: + tmp = RADEON_READ(RADEON_AIC_CNTL) & + ~RS400_MSI_REARM; + RADEON_WRITE(RADEON_AIC_CNTL, tmp); + RADEON_WRITE(RADEON_AIC_CNTL, + tmp | RS400_MSI_REARM); + break; + case CHIP_RS690: + case CHIP_RS740: + tmp = RADEON_READ(RADEON_BUS_CNTL) & + ~RS600_MSI_REARM; + RADEON_WRITE(RADEON_BUS_CNTL, tmp); + RADEON_WRITE(RADEON_BUS_CNTL, tmp | + RS600_MSI_REARM); + break; + default: + tmp = RADEON_READ(RADEON_MSI_REARM_EN) & + ~RV370_MSI_REARM_EN; + RADEON_WRITE(RADEON_MSI_REARM_EN, tmp); + RADEON_WRITE(RADEON_MSI_REARM_EN, + tmp | RV370_MSI_REARM_EN); + break; + } + } return IRQ_HANDLED; } From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 01:58:38 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F315E1065674; Wed, 11 Mar 2009 01:58:37 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF68A8FC1A; Wed, 11 Mar 2009 01:58:37 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B1wbFi080383; Wed, 11 Mar 2009 01:58:37 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B1wbM4080380; Wed, 11 Mar 2009 01:58:37 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110158.n2B1wbM4080380@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 01:58:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189668 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 01:58:38 -0000 Author: rnoland Date: Wed Mar 11 01:58:37 2009 New Revision: 189668 URL: http://svn.freebsd.org/changeset/base/189668 Log: Merge r189052 Turn on MSI if the card supports it. There is a blacklist for chips which report that they are capable of MSI, but don't work correctly. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:58:37 2009 (r189668) @@ -319,6 +319,12 @@ typedef struct drm_pci_id_list char *name; } drm_pci_id_list_t; +struct drm_msi_blacklist_entry +{ + int vendor; + int device; +}; + #define DRM_AUTH 0x1 #define DRM_MASTER 0x2 #define DRM_ROOT_ONLY 0x4 Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:58:37 2009 (r189668) @@ -134,6 +134,27 @@ static struct cdevsw drm_cdevsw = { .d_flags = D_TRACKCLOSE | D_NEEDGIANT }; +static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { + {0x8086, 0x2772}, /* Intel i945G */ \ + {0x8086, 0x27A2}, /* Intel i945GM */ \ + {0x8086, 0x27AE}, /* Intel i945GME */ \ + {0, 0} +}; + +static int drm_msi_is_blacklisted(int vendor, int device) +{ + int i = 0; + + for (i = 0; drm_msi_blacklist[i].vendor != 0; i++) { + if ((drm_msi_blacklist[i].vendor == vendor) && + (drm_msi_blacklist[i].device == device)) { + return 1; + } + } + + return 0; +} + int drm_probe(device_t dev, drm_pci_id_list_t *idlist) { drm_pci_id_list_t *id_entry; @@ -169,7 +190,7 @@ int drm_attach(device_t nbdev, drm_pci_i { struct drm_device *dev; drm_pci_id_list_t *id_entry; - int unit; + int unit, msicount; unit = device_get_unit(nbdev); dev = device_get_softc(nbdev); @@ -189,21 +210,66 @@ int drm_attach(device_t nbdev, drm_pci_i DRM_DEV_MODE, "dri/card%d", unit); +#if __FreeBSD_version >= 700053 + dev->pci_domain = pci_get_domain(dev->device); +#else + dev->pci_domain = 0; +#endif + dev->pci_bus = pci_get_bus(dev->device); + dev->pci_slot = pci_get_slot(dev->device); + dev->pci_func = pci_get_function(dev->device); + + dev->pci_vendor = pci_get_vendor(dev->device); + dev->pci_device = pci_get_device(dev->device); + + if (!drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { + msicount = pci_msi_count(dev->device); + DRM_DEBUG("MSI count = %d\n", msicount); + if (msicount > 1) + msicount = 1; + + if (pci_alloc_msi(dev->device, &msicount) == 0) { + DRM_INFO("MSI enabled %d message(s)\n", msicount); + dev->msi_enabled = 1; + dev->irqrid = 1; + } + } + + dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, + &dev->irqrid, RF_SHAREABLE); + if (!dev->irqr) { + return ENOENT; + } + + dev->irq = (int) rman_get_start(dev->irqr); + mtx_init(&dev->dev_lock, "drmdev", NULL, MTX_DEF); mtx_init(&dev->irq_lock, "drmirq", NULL, MTX_DEF); mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF); mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF); - id_entry = drm_find_description(pci_get_vendor(dev->device), - pci_get_device(dev->device), idlist); + id_entry = drm_find_description(dev->pci_vendor, + dev->pci_device, idlist); dev->id_entry = id_entry; return drm_load(dev); } -int drm_detach(device_t dev) +int drm_detach(device_t nbdev) { - drm_unload(device_get_softc(dev)); + struct drm_device *dev; + + dev = device_get_softc(nbdev); + + drm_unload(dev); + + bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid, dev->irqr); + + if (dev->msi_enabled) { + pci_release_msi(dev->device); + DRM_INFO("MSI released\n"); + } + return 0; } @@ -352,19 +418,6 @@ static int drm_load(struct drm_device *d DRM_DEBUG("\n"); - dev->irq = pci_get_irq(dev->device); -#if __FreeBSD_version >= 700053 - dev->pci_domain = pci_get_domain(dev->device); -#else - dev->pci_domain = 0; -#endif - dev->pci_bus = pci_get_bus(dev->device); - dev->pci_slot = pci_get_slot(dev->device); - dev->pci_func = pci_get_function(dev->device); - - dev->pci_vendor = pci_get_vendor(dev->device); - dev->pci_device = pci_get_device(dev->device); - TAILQ_INIT(&dev->maplist); drm_mem_init(); Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:58:37 2009 (r189668) @@ -172,13 +172,6 @@ int drm_irq_install(struct drm_device *d DRM_UNLOCK(); /* Install handler */ - dev->irqrid = 0; - dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, - &dev->irqrid, RF_SHAREABLE); - if (!dev->irqr) { - retcode = ENOENT; - goto err; - } #if __FreeBSD_version >= 700031 retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY | INTR_MPSAFE, @@ -200,25 +193,17 @@ int drm_irq_install(struct drm_device *d err: DRM_LOCK(); dev->irq_enabled = 0; - if (dev->irqrid != 0) { - bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid, - dev->irqr); - dev->irqrid = 0; - } DRM_UNLOCK(); + return retcode; } int drm_irq_uninstall(struct drm_device *dev) { - int irqrid; - if (!dev->irq_enabled) return EINVAL; dev->irq_enabled = 0; - irqrid = dev->irqrid; - dev->irqrid = 0; DRM_DEBUG("irq=%d\n", dev->irq); @@ -226,7 +211,6 @@ int drm_irq_uninstall(struct drm_device DRM_UNLOCK(); bus_teardown_intr(dev->device, dev->irqr, dev->irqh); - bus_release_resource(dev->device, SYS_RES_IRQ, irqrid, dev->irqr); DRM_LOCK(); drm_vblank_cleanup(dev); From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 02:00:13 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70DA9106566C; Wed, 11 Mar 2009 02:00:13 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E0208FC13; Wed, 11 Mar 2009 02:00:13 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B20Dee080494; Wed, 11 Mar 2009 02:00:13 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B20DKq080493; Wed, 11 Mar 2009 02:00:13 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110200.n2B20DKq080493@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 02:00:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189669 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 02:00:14 -0000 Author: rnoland Date: Wed Mar 11 02:00:13 2009 New Revision: 189669 URL: http://svn.freebsd.org/changeset/base/189669 Log: Merge r189053 Remove D_NEEDGIANT Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:58:37 2009 (r189668) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:00:13 2009 (r189669) @@ -131,7 +131,7 @@ static struct cdevsw drm_cdevsw = { .d_poll = drm_poll, .d_mmap = drm_mmap, .d_name = "drm", - .d_flags = D_TRACKCLOSE | D_NEEDGIANT + .d_flags = D_TRACKCLOSE }; static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 02:13:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FDB110656EB; Wed, 11 Mar 2009 02:13:47 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C41B8FC17; Wed, 11 Mar 2009 02:13:47 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B2DlHK080816; Wed, 11 Mar 2009 02:13:47 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B2DkSW080810; Wed, 11 Mar 2009 02:13:46 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110213.n2B2DkSW080810@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 02:13: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: r189670 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 02:13:48 -0000 Author: rnoland Date: Wed Mar 11 02:13:46 2009 New Revision: 189670 URL: http://svn.freebsd.org/changeset/base/189670 Log: Merge r189054 The GM45 handles vblank differently. Pull the changes from Intel in. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c stable/7/sys/dev/drm/i915_reg.h Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:13:46 2009 (r189670) @@ -868,6 +868,12 @@ int i915_driver_load(struct drm_device * ret = drm_addmap(dev, base, size, _DRM_REGISTERS, _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); + + if (IS_GM45(dev)) + dev->driver->get_vblank_counter = gm45_get_vblank_counter; + else + dev->driver->get_vblank_counter = i915_get_vblank_counter; + #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif Modified: stable/7/sys/dev/drm/i915_drv.c ============================================================================== --- stable/7/sys/dev/drm/i915_drv.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_drv.c Wed Mar 11 02:13:46 2009 (r189670) @@ -81,7 +81,6 @@ static void i915_configure(struct drm_de dev->driver->preclose = i915_driver_preclose; dev->driver->lastclose = i915_driver_lastclose; dev->driver->device_is_agp = i915_driver_device_is_agp; - dev->driver->get_vblank_counter = i915_get_vblank_counter; dev->driver->enable_vblank = i915_enable_vblank; dev->driver->disable_vblank = i915_disable_vblank; dev->driver->irq_preinstall = i915_driver_irq_preinstall; Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:13:46 2009 (r189670) @@ -449,6 +449,7 @@ extern int i915_vblank_pipe_get(struct d extern int i915_enable_vblank(struct drm_device *dev, int crtc); extern void i915_disable_vblank(struct drm_device *dev, int crtc); extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); +extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc); extern int i915_vblank_swap(struct drm_device *dev, void *data, struct drm_file *file_priv); Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:13:46 2009 (r189670) @@ -170,6 +170,19 @@ u32 i915_get_vblank_counter(struct drm_d return count; } +u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) +{ + drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; + int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; + + if (!i915_pipe_enabled(dev, pipe)) { + DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); + return 0; + } + + return I915_READ(reg); +} + irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; Modified: stable/7/sys/dev/drm/i915_reg.h ============================================================================== --- stable/7/sys/dev/drm/i915_reg.h Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_reg.h Wed Mar 11 02:13:46 2009 (r189670) @@ -1329,6 +1329,9 @@ __FBSDID("$FreeBSD$"); #define PIPE_FRAME_LOW_SHIFT 24 #define PIPE_PIXEL_MASK 0x00ffffff #define PIPE_PIXEL_SHIFT 0 +/* GM45+ just has to be different */ +#define PIPEA_FRMCOUNT_GM45 0x70040 +#define PIPEA_FLIPCOUNT_GM45 0x70044 /* Cursor A & B regs */ #define CURACNTR 0x70080 @@ -1397,6 +1400,8 @@ __FBSDID("$FreeBSD$"); #define PIPEBSTAT 0x71024 #define PIPEBFRAMEHIGH 0x71040 #define PIPEBFRAMEPIXEL 0x71044 +#define PIPEB_FRMCOUNT_GM45 0x71040 +#define PIPEB_FLIPCOUNT_GM45 0x71044 /* Display B control */ #define DSPBCNTR 0x71180 From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 02:36:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73BAD1065673; Wed, 11 Mar 2009 02:36:21 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5FFF68FC0A; Wed, 11 Mar 2009 02:36:21 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B2aLs6081296; Wed, 11 Mar 2009 02:36:21 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B2aKvX081293; Wed, 11 Mar 2009 02:36:20 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110236.n2B2aKvX081293@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 02:36: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: r189671 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 02:36:22 -0000 Author: rnoland Date: Wed Mar 11 02:36:20 2009 New Revision: 189671 URL: http://svn.freebsd.org/changeset/base/189671 Log: Merge r189099 Fix up some ioctl permissions issues long overlooked. Submitted by: jkim@ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_bufs.c stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:36:20 2009 (r189671) @@ -901,8 +901,8 @@ int drm_addmap_ioctl(struct drm_device * struct drm_file *file_priv); int drm_rmmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); -int drm_addbufs_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); +int drm_addbufs(struct drm_device *dev, void *data, + struct drm_file *file_priv); int drm_infobufs(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_markbufs(struct drm_device *dev, void *data, Modified: stable/7/sys/dev/drm/drm_bufs.c ============================================================================== --- stable/7/sys/dev/drm/drm_bufs.c Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drm_bufs.c Wed Mar 11 02:36:20 2009 (r189671) @@ -880,8 +880,7 @@ int drm_addbufs_pci(struct drm_device *d return ret; } -int drm_addbufs_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) +int drm_addbufs(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_buf_desc *request = data; int err; Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:36:20 2009 (r189671) @@ -82,7 +82,7 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), @@ -95,10 +95,11 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), + DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER), + DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH), @@ -117,7 +118,6 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 02:37:52 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84F76106566B; Wed, 11 Mar 2009 02:37:52 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71F488FC16; Wed, 11 Mar 2009 02:37:52 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B2bq8i081374; Wed, 11 Mar 2009 02:37:52 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B2bqdD081373; Wed, 11 Mar 2009 02:37:52 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110237.n2B2bqdD081373@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 02:37:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189672 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 02:37:53 -0000 Author: rnoland Date: Wed Mar 11 02:37:52 2009 New Revision: 189672 URL: http://svn.freebsd.org/changeset/base/189672 Log: Merge r189128 Add a tuneable to allow disabling msi on drm at runtime. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:36:20 2009 (r189671) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:37:52 2009 (r189672) @@ -134,6 +134,9 @@ static struct cdevsw drm_cdevsw = { .d_flags = D_TRACKCLOSE }; +int drm_msi = 1; /* Enable by default. */ +TUNABLE_INT("hw.drm.msi", &drm_msi); + static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { {0x8086, 0x2772}, /* Intel i945G */ \ {0x8086, 0x27A2}, /* Intel i945GM */ \ @@ -222,7 +225,8 @@ int drm_attach(device_t nbdev, drm_pci_i dev->pci_vendor = pci_get_vendor(dev->device); dev->pci_device = pci_get_device(dev->device); - if (!drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { + if (drm_msi && + !drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { msicount = pci_msi_count(dev->device); DRM_DEBUG("MSI count = %d\n", msicount); if (msicount > 1) From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 02:39:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4029106564A; Wed, 11 Mar 2009 02:39:03 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9E3B48FC16; Wed, 11 Mar 2009 02:39:03 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2B2d3TD081459; Wed, 11 Mar 2009 02:39:03 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2B2d2kY081443; Wed, 11 Mar 2009 02:39:02 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903110239.n2B2d2kY081443@svn.freebsd.org> From: Robert Noland Date: Wed, 11 Mar 2009 02:39:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189673 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 02:39:04 -0000 Author: rnoland Date: Wed Mar 11 02:39:02 2009 New Revision: 189673 URL: http://svn.freebsd.org/changeset/base/189673 Log: Merge 189130 Initialize the vblank structures at load time. Previously we did this at irq install/uninstall time, but when we vt switch, we uninstall the irq handler. When the irq handler is reinstalled, the modeset ioctl happens first. The modeset ioctl is supposed to tell us that we can disable vblank interrupts if there are no active consumers. This will fail after a vt switch until another modeset ioctl is called via dpms or xrandr. Leading to cases where either interrupts are on and can't be disabled, or worse, no interrupts at all. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c stable/7/sys/dev/drm/mach64_drv.c stable/7/sys/dev/drm/mach64_drv.h stable/7/sys/dev/drm/mach64_irq.c stable/7/sys/dev/drm/mga_dma.c stable/7/sys/dev/drm/mga_irq.c stable/7/sys/dev/drm/r128_drv.c stable/7/sys/dev/drm/r128_drv.h stable/7/sys/dev/drm/r128_irq.c stable/7/sys/dev/drm/radeon_cp.c stable/7/sys/dev/drm/radeon_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:39:02 2009 (r189673) @@ -794,6 +794,7 @@ void drm_handle_vblank(struct drm_device u32 drm_vblank_count(struct drm_device *dev, int crtc); int drm_vblank_get(struct drm_device *dev, int crtc); void drm_vblank_put(struct drm_device *dev, int crtc); +void drm_vblank_cleanup(struct drm_device *dev); int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); int drm_vblank_init(struct drm_device *dev, int num_crtcs); void drm_vbl_send_signals(struct drm_device *dev, int crtc); Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -523,6 +523,8 @@ static void drm_unload(struct drm_device DRM_DEBUG("mtrr_del = %d", retcode); } + drm_vblank_cleanup(dev); + DRM_LOCK(); drm_lastclose(dev); DRM_UNLOCK(); Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -96,7 +96,7 @@ static void vblank_disable_fn(void *arg) } } -static void drm_vblank_cleanup(struct drm_device *dev) +void drm_vblank_cleanup(struct drm_device *dev) { unsigned long irqflags; @@ -213,8 +213,6 @@ int drm_irq_uninstall(struct drm_device bus_teardown_intr(dev->device, dev->irqr, dev->irqh); DRM_LOCK(); - drm_vblank_cleanup(dev); - return 0; } Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:39:02 2009 (r189673) @@ -902,6 +902,13 @@ int i915_driver_load(struct drm_device * #endif DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); + ret = drm_vblank_init(dev, I915_NUM_PIPE); + + if (ret) { + (void) i915_driver_unload(dev); + return ret; + } + return ret; } Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -49,6 +49,8 @@ enum pipe { PIPE_B, }; +#define I915_NUM_PIPE 2 + /* Interface history: * * 1.1: Original. Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -484,11 +484,6 @@ void i915_driver_irq_preinstall(struct d int i915_driver_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - int ret, num_pipes = 2; - - ret = drm_vblank_init(dev, num_pipes); - if (ret) - return ret; dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; Modified: stable/7/sys/dev/drm/mach64_drv.c ============================================================================== --- stable/7/sys/dev/drm/mach64_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -54,6 +54,7 @@ static void mach64_configure(struct drm_ DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = 1; /* No dev_priv */ + dev->driver->load = mach64_driver_load; dev->driver->lastclose = mach64_driver_lastclose; dev->driver->get_vblank_counter = mach64_get_vblank_counter; dev->driver->enable_vblank = mach64_enable_vblank; @@ -94,6 +95,12 @@ mach64_attach(device_t nbdev) return drm_attach(nbdev, mach64_pciidlist); } +int +mach64_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int mach64_detach(device_t nbdev) { Modified: stable/7/sys/dev/drm/mach64_drv.h ============================================================================== --- stable/7/sys/dev/drm/mach64_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -166,6 +166,7 @@ extern int mach64_dma_blit(struct drm_de extern int mach64_get_param(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int mach64_driver_load(struct drm_device * dev, unsigned long flags); extern u32 mach64_get_vblank_counter(struct drm_device *dev, int crtc); extern int mach64_enable_vblank(struct drm_device *dev, int crtc); extern void mach64_disable_vblank(struct drm_device *dev, int crtc); Modified: stable/7/sys/dev/drm/mach64_irq.c ============================================================================== --- stable/7/sys/dev/drm/mach64_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -146,7 +146,7 @@ void mach64_driver_irq_preinstall(struct int mach64_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void mach64_driver_irq_uninstall(struct drm_device * dev) Modified: stable/7/sys/dev/drm/mga_dma.c ============================================================================== --- stable/7/sys/dev/drm/mga_dma.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mga_dma.c Wed Mar 11 02:39:02 2009 (r189673) @@ -399,6 +399,7 @@ int mga_freelist_put(struct drm_device * int mga_driver_load(struct drm_device *dev, unsigned long flags) { drm_mga_private_t *dev_priv; + int ret; dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); if (!dev_priv) @@ -418,6 +419,13 @@ int mga_driver_load(struct drm_device *d dev->types[7] = _DRM_STAT_PRIMARY; dev->types[8] = _DRM_STAT_SECONDARY; + ret = drm_vblank_init(dev, 1); + + if (ret) { + (void) mga_driver_unload(dev); + return ret; + } + return 0; } Modified: stable/7/sys/dev/drm/mga_irq.c ============================================================================== --- stable/7/sys/dev/drm/mga_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mga_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -157,11 +157,6 @@ void mga_driver_irq_preinstall(struct dr int mga_driver_irq_postinstall(struct drm_device * dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - int ret; - - ret = drm_vblank_init(dev, 1); - if (ret) - return ret; DRM_INIT_WAITQUEUE(&dev_priv->fence_queue); Modified: stable/7/sys/dev/drm/r128_drv.c ============================================================================== --- stable/7/sys/dev/drm/r128_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -52,6 +52,7 @@ static void r128_configure(struct drm_de DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = sizeof(drm_r128_buf_priv_t); + dev->driver->load = r128_driver_load; dev->driver->preclose = r128_driver_preclose; dev->driver->lastclose = r128_driver_lastclose; dev->driver->get_vblank_counter = r128_get_vblank_counter; @@ -93,6 +94,11 @@ r128_attach(device_t nbdev) return drm_attach(nbdev, r128_pciidlist); } +int r128_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int r128_detach(device_t nbdev) { Modified: stable/7/sys/dev/drm/r128_drv.h ============================================================================== --- stable/7/sys/dev/drm/r128_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -162,6 +162,7 @@ extern void r128_driver_irq_preinstall(s extern int r128_driver_irq_postinstall(struct drm_device * dev); extern void r128_driver_irq_uninstall(struct drm_device * dev); extern void r128_driver_lastclose(struct drm_device * dev); +extern int r128_driver_load(struct drm_device * dev, unsigned long flags); extern void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv); Modified: stable/7/sys/dev/drm/r128_irq.c ============================================================================== --- stable/7/sys/dev/drm/r128_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -105,7 +105,7 @@ void r128_driver_irq_preinstall(struct d int r128_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void r128_driver_irq_uninstall(struct drm_device * dev) Modified: stable/7/sys/dev/drm/radeon_cp.c ============================================================================== --- stable/7/sys/dev/drm/radeon_cp.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/radeon_cp.c Wed Mar 11 02:39:02 2009 (r189673) @@ -1751,6 +1751,12 @@ int radeon_driver_load(struct drm_device else dev_priv->flags |= RADEON_IS_PCI; + ret = drm_vblank_init(dev, 2); + if (ret) { + radeon_driver_unload(dev); + return ret; + } + DRM_DEBUG("%s card detected\n", ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI")))); return ret; Modified: stable/7/sys/dev/drm/radeon_irq.c ============================================================================== --- stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -372,15 +372,10 @@ int radeon_driver_irq_postinstall(struct { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; - int ret; atomic_set(&dev_priv->swi_emitted, 0); DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); - ret = drm_vblank_init(dev, 2); - if (ret) - return ret; - dev->max_vblank_count = 0x001fffff; radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); From owner-svn-src-stable@FreeBSD.ORG Wed Mar 11 22:13:12 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C89711065670; Wed, 11 Mar 2009 22:13:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B52CF8FC15; Wed, 11 Mar 2009 22:13:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2BMDCpV008053; Wed, 11 Mar 2009 22:13:12 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2BMDCkr008048; Wed, 11 Mar 2009 22:13:12 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903112213.n2BMDCkr008048@svn.freebsd.org> From: John Baldwin Date: Wed, 11 Mar 2009 22:13:12 +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: r189709 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/cd9660 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 22:13:13 -0000 Author: jhb Date: Wed Mar 11 22:13:12 2009 New Revision: 189709 URL: http://svn.freebsd.org/changeset/base/189709 Log: MFC: Make cd9660 MPSAFE and able to use shared vnode locks for pathname lookups. Also, disable operations on character device nodes. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/cd9660/cd9660_lookup.c stable/7/sys/fs/cd9660/cd9660_node.c stable/7/sys/fs/cd9660/cd9660_node.h stable/7/sys/fs/cd9660/cd9660_vfsops.c stable/7/sys/fs/cd9660/cd9660_vnops.c Modified: stable/7/sys/fs/cd9660/cd9660_lookup.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_lookup.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_lookup.c Wed Mar 11 22:13:12 2009 (r189709) @@ -94,29 +94,34 @@ cd9660_lookup(ap) struct iso_node *dp; /* inode for directory being searched */ struct iso_mnt *imp; /* filesystem that directory is in */ struct buf *bp; /* a buffer of directory entries */ - struct iso_directory_record *ep = 0;/* the current directory entry */ + struct iso_directory_record *ep;/* the current directory entry */ + struct iso_directory_record *ep2;/* copy of current directory entry */ int entryoffsetinblock; /* offset of ep in bp's buffer */ int saveoffset = 0; /* offset of last directory entry in dir */ + doff_t i_diroff; /* cached i_diroff value. */ + doff_t i_offset; /* cached i_offset value. */ int numdirpasses; /* strategy for directory search */ doff_t endsearch; /* offset to end directory search */ struct vnode *pdp; /* saved dp during symlink work */ struct vnode *tdp; /* returned by cd9660_vget_internal */ u_long bmask; /* block offset mask */ int error; - ino_t ino = 0, saved_ino; - int reclen; + ino_t ino, i_ino; + int ltype, reclen; u_short namelen; int isoflags; char altname[NAME_MAX]; int res; int assoc, len; char *name; + struct mount *mp; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; struct thread *td = cnp->cn_thread; + ep2 = ep = NULL; bp = NULL; *vpp = NULL; vdp = ap->a_dvp; @@ -126,9 +131,11 @@ cd9660_lookup(ap) /* * We now have a segment name to search for, and a directory to search. */ - + ino = reclen = 0; + i_diroff = dp->i_diroff; len = cnp->cn_namelen; name = cnp->cn_nameptr; + /* * A leading `=' means, we are looking for an associated file */ @@ -150,15 +157,14 @@ cd9660_lookup(ap) * of simplicity. */ bmask = imp->im_bmask; - if (nameiop != LOOKUP || dp->i_diroff == 0 || - dp->i_diroff > dp->i_size) { + if (nameiop != LOOKUP || i_diroff == 0 || i_diroff > dp->i_size) { entryoffsetinblock = 0; - dp->i_offset = 0; + i_offset = 0; numdirpasses = 1; } else { - dp->i_offset = dp->i_diroff; - if ((entryoffsetinblock = dp->i_offset & bmask) && - (error = cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp))) + i_offset = i_diroff; + if ((entryoffsetinblock = i_offset & bmask) && + (error = cd9660_blkatoff(vdp, (off_t)i_offset, NULL, &bp))) return (error); numdirpasses = 2; nchstats.ncs_2passes++; @@ -166,17 +172,17 @@ cd9660_lookup(ap) endsearch = dp->i_size; searchloop: - while (dp->i_offset < endsearch) { + while (i_offset < endsearch) { /* * If offset is on a block boundary, * read the next directory block. * Release previous if it exists. */ - if ((dp->i_offset & bmask) == 0) { + if ((i_offset & bmask) == 0) { if (bp != NULL) brelse(bp); if ((error = - cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)) != 0) + cd9660_blkatoff(vdp, (off_t)i_offset, NULL, &bp)) != 0) return (error); entryoffsetinblock = 0; } @@ -189,8 +195,8 @@ searchloop: reclen = isonum_711(ep->length); if (reclen == 0) { /* skip to next block, if any */ - dp->i_offset = - (dp->i_offset & ~bmask) + imp->logical_block_size; + i_offset = + (i_offset & ~bmask) + imp->logical_block_size; continue; } @@ -225,7 +231,7 @@ searchloop: * Save directory entry's inode number and * release directory buffer. */ - dp->i_ino = isodirino(ep, imp); + i_ino = isodirino(ep, imp); goto found; } if (namelen != 1 @@ -242,7 +248,7 @@ searchloop: else ino = dbtob(bp->b_blkno) + entryoffsetinblock; - saveoffset = dp->i_offset; + saveoffset = i_offset; } else if (ino) goto foundino; #ifdef NOSORTBUG /* On some CDs directory entries are not sorted correctly */ @@ -258,22 +264,22 @@ searchloop: ino = isodirino(ep, imp); else ino = dbtob(bp->b_blkno) + entryoffsetinblock; - dp->i_ino = ino; - cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp); + i_ino = ino; + cd9660_rrip_getname(ep, altname, &namelen, &i_ino, imp); if (namelen == cnp->cn_namelen && !bcmp(name,altname,namelen)) goto found; ino = 0; break; } - dp->i_offset += reclen; + i_offset += reclen; entryoffsetinblock += reclen; } if (ino) { foundino: - dp->i_ino = ino; - if (saveoffset != dp->i_offset) { - if (lblkno(imp, dp->i_offset) != + i_ino = ino; + if (saveoffset != i_offset) { + if (lblkno(imp, i_offset) != lblkno(imp, saveoffset)) { if (bp != NULL) brelse(bp); @@ -284,7 +290,8 @@ foundino: entryoffsetinblock = saveoffset & bmask; ep = (struct iso_directory_record *) ((char *)bp->b_data + entryoffsetinblock); - dp->i_offset = saveoffset; + reclen = isonum_711(ep->length); + i_offset = saveoffset; } goto found; } @@ -295,8 +302,8 @@ notfound: */ if (numdirpasses == 2) { numdirpasses--; - dp->i_offset = 0; - endsearch = dp->i_diroff; + i_offset = 0; + endsearch = i_diroff; goto searchloop; } if (bp != NULL) @@ -321,10 +328,10 @@ found: * in the cache as to where the entry was found. */ if ((flags & ISLASTCN) && nameiop == LOOKUP) - dp->i_diroff = dp->i_offset; + dp->i_diroff = i_offset; /* - * Step through the translation in the name. We do not `iput' the + * Step through the translation in the name. We do not `vput' the * directory because we may need it again if a symbolic link * is relative to the current directory. Instead we save it * unlocked as "pdp". We must get the target inode before unlocking @@ -334,7 +341,7 @@ found: * when following backward pointers ".." we must unlock the * parent directory before getting the requested directory. * There is a potential race condition here if both the current - * and parent directories are removed before the `iget' for the + * and parent directories are removed before the `vget' for the * inode associated with ".." returns. We hope that this occurs * infrequently since we cannot avoid this race condition without * implementing a sophisticated deadlock detection algorithm. @@ -343,30 +350,75 @@ found: * that point backwards in the directory structure. */ pdp = vdp; + /* - * If ino is different from dp->i_ino, + * Make a copy of the directory entry for non "." lookups so + * we can drop the buffer before calling vget() to avoid a + * lock order reversal between the vnode lock and the buffer + * lock. + */ + if (dp->i_number != i_ino) { + ep2 = malloc(reclen, M_TEMP, M_WAITOK); + bcopy(ep, ep2, reclen); + ep = ep2; + } + brelse(bp); + + /* + * If ino is different from i_ino, * it's a relocated directory. */ if (flags & ISDOTDOT) { - saved_ino = dp->i_ino; - VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ - error = cd9660_vget_internal(vdp->v_mount, saved_ino, - LK_EXCLUSIVE, &tdp, - saved_ino != ino, ep); - brelse(bp); - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); + /* + * Expanded copy of vn_vget_ino() so that we can use + * cd9660_vget_internal(). + */ + mp = pdp->v_mount; + ltype = VOP_ISLOCKED(pdp, td); + for (;;) { + error = vfs_busy(mp, LK_NOWAIT, NULL, curthread); + if (error == 0) + break; + VOP_UNLOCK(pdp, 0, td); + pause("vn_vget", 1); + vn_lock(pdp, ltype | LK_RETRY, td); + if (pdp->v_iflag & VI_DOOMED) + return (ENOENT); + } + VOP_UNLOCK(pdp, 0, td); + error = cd9660_vget_internal(vdp->v_mount, i_ino, + cnp->cn_lkflags, &tdp, + i_ino != ino, ep); + free(ep2, M_TEMP); + vfs_unbusy(mp, td); + vn_lock(pdp, ltype | LK_RETRY, td); + if (pdp->v_iflag & VI_DOOMED) { + if (error == 0) + vput(tdp); + error = ENOENT; + } if (error) return (error); *vpp = tdp; - } else if (dp->i_number == dp->i_ino) { - brelse(bp); + } else if (dp->i_number == i_ino) { VREF(vdp); /* we want ourself, ie "." */ + /* + * When we lookup "." we still can be asked to lock it + * differently. + */ + ltype = cnp->cn_lkflags & LK_TYPE_MASK; + if (ltype != VOP_ISLOCKED(vdp, td)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(vdp, LK_UPGRADE | LK_RETRY, td); + else /* if (ltype == LK_SHARED) */ + vn_lock(vdp, LK_DOWNGRADE | LK_RETRY, td); + } *vpp = vdp; } else { - error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, - LK_EXCLUSIVE, &tdp, - dp->i_ino != ino, ep); - brelse(bp); + error = cd9660_vget_internal(vdp->v_mount, i_ino, + cnp->cn_lkflags, &tdp, + i_ino != ino, ep); + free(ep2, M_TEMP); if (error) return (error); *vpp = tdp; Modified: stable/7/sys/fs/cd9660/cd9660_node.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_node.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_node.c Wed Mar 11 22:13:12 2009 (r189709) @@ -93,7 +93,6 @@ cd9660_reclaim(ap) } */ *ap; { struct vnode *vp = ap->a_vp; - struct iso_node *ip = VTOI(vp); if (prtactive && vrefcnt(vp) != 0) vprint("cd9660_reclaim: pushing active", vp); @@ -109,8 +108,6 @@ cd9660_reclaim(ap) /* * Purge old data structures associated with the inode. */ - if (ip->i_mnt->im_devvp) - vrele(ip->i_mnt->im_devvp); FREE(vp->v_data, M_ISOFSNODE); vp->v_data = NULL; return (0); Modified: stable/7/sys/fs/cd9660/cd9660_node.h ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_node.h Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_node.h Wed Mar 11 22:13:12 2009 (r189709) @@ -65,8 +65,6 @@ struct iso_node { struct lockf *i_lockf; /* head of byte-level lock list */ doff_t i_endoff; /* end of useful stuff in directory */ doff_t i_diroff; /* offset in dir, where we found last entry */ - doff_t i_offset; /* offset of free space in directory */ - ino_t i_ino; /* inode number of found directory */ long iso_extent; /* extent of file */ unsigned long i_size; Modified: stable/7/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 11 22:13:12 2009 (r189709) @@ -381,6 +381,7 @@ iso_mountfs(devvp, mp, td) mp->mnt_maxsymlinklen = 0; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED; MNT_IUNLOCK(mp); isomp->im_mountp = mp; isomp->im_dev = dev; @@ -556,7 +557,7 @@ cd9660_root(mp, flags, vpp, td) * With RRIP we must use the `.' entry of the root directory. * Simply tell vget, that it's a relocated directory. */ - return (cd9660_vget_internal(mp, ino, LK_EXCLUSIVE, vpp, + return (cd9660_vget_internal(mp, ino, flags, vpp, imp->iso_ftype == ISO_FTYPE_RRIP, dp)); } @@ -670,6 +671,22 @@ cd9660_vget_internal(mp, ino, flags, vpp if (error || *vpp != NULL) return (error); + /* + * We must promote to an exclusive lock for vnode creation. This + * can happen if lookup is passed LOCKSHARED. + */ + if ((flags & LK_TYPE_MASK) == LK_SHARED) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } + + /* + * We do not lock vnode creation as it is believed to be too + * expensive for such rare case as simultaneous creation of vnode + * for same ino by different processes. We just allow them to race + * and check later to decide who wins. Let the race begin! + */ + imp = VFSTOISOFS(mp); dev = imp->im_dev; @@ -750,7 +767,6 @@ cd9660_vget_internal(mp, ino, flags, vpp bp = 0; ip->i_mnt = imp; - VREF(imp->im_devvp); if (relocated) { /* @@ -808,6 +824,7 @@ cd9660_vget_internal(mp, ino, flags, vpp vp->v_op = &cd9660_fifoops; break; default: + vp->v_vnlock->lk_flags &= ~LK_NOSHARE; break; } Modified: stable/7/sys/fs/cd9660/cd9660_vnops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vnops.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_vnops.c Wed Mar 11 22:13:12 2009 (r189709) @@ -169,10 +169,14 @@ cd9660_open(ap) int a_fdidx; } */ *ap; { - struct iso_node *ip = VTOI(ap->a_vp); + struct vnode *vp = ap->a_vp; + struct iso_node *ip = VTOI(vp); - vnode_create_vobject(ap->a_vp, ip->i_size, ap->a_td); - return 0; + if (vp->v_type == VCHR || vp->v_type == VBLK) + return (EOPNOTSUPP); + + vnode_create_vobject(vp, ip->i_size, ap->a_td); + return (0); } From owner-svn-src-stable@FreeBSD.ORG Thu Mar 12 03:09:13 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53F20106564A; Thu, 12 Mar 2009 03:09:13 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3CAAD8FC0A; Thu, 12 Mar 2009 03:09:13 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2C39Dwk015082; Thu, 12 Mar 2009 03:09:13 GMT (envelope-from bms@svn.freebsd.org) Received: (from bms@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2C39C62015056; Thu, 12 Mar 2009 03:09:12 GMT (envelope-from bms@svn.freebsd.org) Message-Id: <200903120309.n2C39C62015056@svn.freebsd.org> From: Bruce M Simpson Date: Thu, 12 Mar 2009 03:09:12 +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: r189720 - in stable/7: . sys/amd64/conf sys/arm/conf sys/conf sys/dev/ath sys/dev/ath/ath_rate/amrr sys/dev/ath/ath_rate/onoe sys/dev/ath/ath_rate/sample sys/i386/conf sys/modules sys/m... X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 03:09:14 -0000 Author: bms Date: Thu Mar 12 03:09:11 2009 New Revision: 189720 URL: http://svn.freebsd.org/changeset/base/189720 Log: Merge the open source Atheros HAL from HEAD to STABLE. This adds support for the AH_SUPPORT_AR5416 kernel configuration option, and removes the ath_rate* and ath_hal modules. Their kernel options are not however removed -- please see UPDATING. Tested on an IBM/Lenovo T43 and ASUS EeePC 701 in both STA and HostAP modes. Submitted by: sam Deleted: stable/7/sys/modules/ath_hal/ stable/7/sys/modules/ath_rate_amrr/ stable/7/sys/modules/ath_rate_onoe/ stable/7/sys/modules/ath_rate_sample/ Modified: stable/7/UPDATING stable/7/sys/amd64/conf/GENERIC stable/7/sys/amd64/conf/NOTES stable/7/sys/arm/conf/AVILA stable/7/sys/conf/files stable/7/sys/conf/files.amd64 stable/7/sys/conf/files.arm stable/7/sys/conf/files.i386 stable/7/sys/conf/files.pc98 stable/7/sys/conf/files.powerpc stable/7/sys/conf/files.sparc64 stable/7/sys/conf/kern.pre.mk stable/7/sys/conf/options stable/7/sys/dev/ath/ah_osdep.c stable/7/sys/dev/ath/ah_osdep.h stable/7/sys/dev/ath/ath_rate/amrr/amrr.c stable/7/sys/dev/ath/ath_rate/onoe/onoe.c stable/7/sys/dev/ath/ath_rate/sample/sample.c stable/7/sys/dev/ath/if_ath.c stable/7/sys/dev/ath/if_ath_pci.c stable/7/sys/dev/ath/if_athvar.h stable/7/sys/i386/conf/GENERIC stable/7/sys/i386/conf/NOTES stable/7/sys/modules/Makefile stable/7/sys/modules/ath/Makefile stable/7/sys/pc98/conf/GENERIC stable/7/sys/pc98/conf/NOTES stable/7/sys/sparc64/conf/GENERIC Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/UPDATING Thu Mar 12 03:09:11 2009 (r189720) @@ -8,6 +8,16 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20090312: + The open-source Atheros HAL has been merged from HEAD + to STABLE. + The kernel compile-time option AH_SUPPORT_AR5416 has been + added to support certain newer Atheros parts, particularly + PCI-Express chipsets. + The following modules are no longer available, and should be + removed from MODULES_OVERRIDE and/or loader.conf:- + ath_hal ath_rate_amrr ath_rate_onoe ath_rate_sample + 20090207: ZFS users on amd64 machines with 4GB or more of RAM should reevaluate their need for setting vm.kmem_size_max and Modified: stable/7/sys/amd64/conf/GENERIC ============================================================================== --- stable/7/sys/amd64/conf/GENERIC Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/amd64/conf/GENERIC Thu Mar 12 03:09:11 2009 (r189720) @@ -242,6 +242,7 @@ device wlan_scan_sta # 802.11 STA mode device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. Modified: stable/7/sys/amd64/conf/NOTES ============================================================================== --- stable/7/sys/amd64/conf/NOTES Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/amd64/conf/NOTES Thu Mar 12 03:09:11 2009 (r189720) @@ -331,6 +331,7 @@ device wpi device ath device ath_hal # Atheros HAL (includes binary component) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_amrr # AMRR rate control for ath driver #device ath_rate_onoe # Onoe rate control for ath driver device ath_rate_sample # SampleRate rate control for the ath driver Modified: stable/7/sys/arm/conf/AVILA ============================================================================== --- stable/7/sys/arm/conf/AVILA Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/arm/conf/AVILA Thu Mar 12 03:09:11 2009 (r189720) @@ -133,6 +133,7 @@ device wlan # 802.11 support #device wlan_tkip # 802.11 TKIP support device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath options ATH_DEBUG Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files Thu Mar 12 03:09:11 2009 (r189720) @@ -475,18 +475,180 @@ dev/ata/atapi-cam.c optional atapicam dev/ata/atapi-cd.c optional atapicd dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist -dev/ath/ah_osdep.c optional ath_hal \ +# +dev/ath/if_ath.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/if_ath_pci.c optional ath pci \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ah_osdep.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v1.c optional ath_hal | ath_ar5210 \ compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v3.c optional ath_hal | ath_ar5211 | ath_ar5212 \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v14.c optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_regdomain.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ar5210/ar5210_attach.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_beacon.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_interrupts.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_keycache.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_misc.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_phy.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_power.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_recv.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_reset.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_xmit.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_attach.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_beacon.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_interrupts.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_keycache.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_misc.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_phy.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_power.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_recv.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_reset.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_xmit.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_ani.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_attach.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_beacon.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_eeprom.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_gpio.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_interrupts.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_keycache.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_misc.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_phy.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_power.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_recv.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_reset.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_rfgain.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_xmit.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2316.c optional ath_rf2316 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2317.c optional ath_rf2317 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2413.c optional ath_hal | ath_rf2413 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2425.c optional ath_hal | ath_rf2425 | ath_rf2417 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5111.c optional ath_hal | ath_rf5111 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5112.c optional ath_hal | ath_rf5112 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5413.c optional ath_hal | ath_rf5413 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar2133.c optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_ani.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_attach.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_beacon.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_iq.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_adcgain.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_adcdc.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_eeprom.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_gpio.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_interrupts.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_keycache.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_misc.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_phy.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_power.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_recv.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_reset.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_xmit.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar9160_attach.c optional ath_hal | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_rate/onoe/onoe.c optional ath_rate_onoe \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_rate/sample/sample.c optional ath_rate_sample \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath.c optional ath \ - compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_pci.c optional ath pci \ - compile-with "${NORMAL_C} -I$S/dev/ath" dev/awi/am79c930.c optional awi dev/awi/awi.c optional awi dev/awi/if_awi_pccard.c optional awi pccard Modified: stable/7/sys/conf/files.amd64 ============================================================================== --- stable/7/sys/conf/files.amd64 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.amd64 Thu Mar 12 03:09:11 2009 (r189720) @@ -47,16 +47,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/x86_64-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/x86_64-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/x86_64-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/x86_64-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# nvenetlib.o optional nve pci \ dependency "$S/contrib/dev/nve/amd64/nvenetlib.o.bz2.uu" \ compile-with "uudecode $S/contrib/dev/nve/amd64/nvenetlib.o.bz2.uu ; bzip2 -df nvenetlib.o.bz2" \ Modified: stable/7/sys/conf/files.arm ============================================================================== --- stable/7/sys/conf/files.arm Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.arm Thu Mar 12 03:09:11 2009 (r189720) @@ -52,13 +52,6 @@ geom/geom_bsd.c standard geom/geom_bsd_enc.c standard geom/geom_mbr.c standard geom/geom_mbr_enc.c standard -hal.o optional ath_hal \ - compile-with "ATH_HAL_CPU=`echo ${CONF_CFLAGS}|sed 's/.*-mcpu=\([a-zA-Z0-9]*\).*/\1/'`; ATH_ENDIAN=`if (echo ${CC}|grep mbig-endian>/dev/null); then echo be; else echo le; fi;`; uudecode < $S/contrib/dev/ath/public/$$ATH_HAL_CPU-$$ATH_ENDIAN-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - compile-with "ATH_HAL_CPU=`echo ${CONF_CFLAGS}|sed 's/.*-mcpu=\([a-zA-Z0-9]*\).*/\1/'`; ATH_ENDIAN=`if (echo ${CC}|grep mbig-endian>/dev/null); then echo be; else echo le; fi;`; rm -f opt_ah.h; cp $S/contrib/dev/ath/public/$$ATH_HAL_CPU-$$ATH_ENDIAN-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" libkern/arm/divsi3.S standard libkern/arm/ffs.S standard libkern/arm/muldi3.c standard Modified: stable/7/sys/conf/files.i386 ============================================================================== --- stable/7/sys/conf/files.i386 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.i386 Thu Mar 12 03:09:11 2009 (r189720) @@ -51,16 +51,6 @@ trlld.o optional oltr \ compile-with "uudecode < $S/contrib/dev/oltr/i386-elf.trlld.o.uu" \ no-implicit-rule # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/i386-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# nvenetlib.o optional nve pci \ dependency "$S/contrib/dev/nve/i386/nvenetlib.o.bz2.uu" \ compile-with "uudecode $S/contrib/dev/nve/i386/nvenetlib.o.bz2.uu ; bzip2 -df nvenetlib.o.bz2" \ Modified: stable/7/sys/conf/files.pc98 ============================================================================== --- stable/7/sys/conf/files.pc98 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.pc98 Thu Mar 12 03:09:11 2009 (r189720) @@ -43,16 +43,6 @@ trlld.o optional oltr \ compile-with "uudecode < $S/contrib/dev/oltr/i386-elf.trlld.o.uu" \ no-implicit-rule # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/i386-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs compat/linux/linux_emul.c optional compat_linux Modified: stable/7/sys/conf/files.powerpc ============================================================================== --- stable/7/sys/conf/files.powerpc Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.powerpc Thu Mar 12 03:09:11 2009 (r189720) @@ -14,16 +14,6 @@ font.h optional no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/powerpc-be-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/powerpc-be-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/powerpc-be-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/powerpc-be-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# dev/bm/if_bm.c optional bm powermac dev/fb/fb.c optional sc Modified: stable/7/sys/conf/files.sparc64 ============================================================================== --- stable/7/sys/conf/files.sparc64 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.sparc64 Thu Mar 12 03:09:11 2009 (r189720) @@ -22,16 +22,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/sparc64-be-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/sparc64-be-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/sparc64-be-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/sparc64-be-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/atkbdc/atkbd.c optional atkbd atkbdc Modified: stable/7/sys/conf/kern.pre.mk ============================================================================== --- stable/7/sys/conf/kern.pre.mk Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/kern.pre.mk Thu Mar 12 03:09:11 2009 (r189720) @@ -65,8 +65,8 @@ INCLUDES+= -I$S/contrib/ipfilter # ... and the same for pf INCLUDES+= -I$S/contrib/pf -# ... and the same for Atheros HAL -INCLUDES+= -I$S/dev/ath +# ... and the same for ath +INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal # ... and the same for the NgATM stuff INCLUDES+= -I$S/contrib/ngatm Modified: stable/7/sys/conf/options ============================================================================== --- stable/7/sys/conf/options Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/options Thu Mar 12 03:09:11 2009 (r189720) @@ -729,6 +729,21 @@ ATH_RXBUF opt_ath.h ATH_DIAGAPI opt_ath.h ATH_TX99_DIAG opt_ath.h +# options for the Atheros hal +AH_SUPPORT_AR5416 opt_ah.h + +AH_DEBUG opt_ah.h +AH_ASSERT opt_ah.h +AH_DEBUG_ALQ opt_ah.h +AH_REGOPS_FUNC opt_ah.h +AH_WRITE_REGDOMAIN opt_ah.h +AH_DEBUG_COUNTRY opt_ah.h +AH_WRITE_EEPROM opt_ah.h +AH_PRIVATE_DIAG opt_ah.h +AH_NEED_DESC_SWAP opt_ah.h +AH_USE_INIPDGAIN opt_ah.h +AH_SUPPORT_11D opt_ah.h + # dcons options DCONS_BUF_SIZE opt_dcons.h DCONS_POLL_HZ opt_dcons.h Modified: stable/7/sys/dev/ath/ah_osdep.c ============================================================================== --- stable/7/sys/dev/ath/ah_osdep.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ah_osdep.c Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ #include /* XXX for ether_sprintf */ -#include +#include /* * WiSoC boards overload the bus tag with information about the @@ -56,7 +56,7 @@ #define BUSTAG(ah) \ ((bus_space_tag_t) ((struct ar531x_config *)((ah)->ah_st))->tag) #else -#define BUSTAG(ah) ((bus_space_tag_t) (ah)->ah_st) +#define BUSTAG(ah) ((ah)->ah_st) #endif extern void ath_hal_printf(struct ath_hal *, const char*, ...) @@ -71,8 +71,12 @@ extern void ath_hal_assert_failed(const int lineno, const char* msg); #endif #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +extern void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...); +#else extern void HALDEBUG(struct ath_hal *ah, const char* fmt, ...); extern void HALDEBUGn(struct ath_hal *ah, u_int level, const char* fmt, ...); +#endif #endif /* AH_DEBUG */ /* NB: put this here instead of the driver to avoid circular references */ @@ -86,9 +90,6 @@ SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); #endif /* AH_DEBUG */ -SYSCTL_STRING(_hw_ath_hal, OID_AUTO, version, CTLFLAG_RD, ath_hal_version, 0, - "Atheros HAL version"); - /* NB: these are deprecated; they exist for now for compatibility */ int ath_hal_dma_beacon_response_time = 2; /* in TU's */ SYSCTL_INT(_hw_ath_hal, OID_AUTO, dma_brt, CTLFLAG_RW, @@ -139,6 +140,18 @@ ath_hal_ether_sprintf(const u_int8_t *ma } #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +void +HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) +{ + if (ath_hal_debug & mask) { + __va_list ap; + va_start(ap, fmt); + ath_hal_vprintf(ah, fmt, ap); + va_end(ap); + } +} +#else void HALDEBUG(struct ath_hal *ah, const char* fmt, ...) { @@ -160,6 +173,7 @@ HALDEBUGn(struct ath_hal *ah, u_int leve va_end(ap); } } +#endif #endif /* AH_DEBUG */ #ifdef AH_DEBUG_ALQ @@ -178,7 +192,7 @@ HALDEBUGn(struct ath_hal *ah, u_int leve */ #include #include -#include +#include static struct alq *ath_hal_alq; static int ath_hal_alq_emitdev; /* need to emit DEVICE record */ @@ -256,7 +270,7 @@ void ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; if (ath_hal_alq) { struct ale *ale = ath_hal_alq_get(ah); @@ -280,7 +294,7 @@ u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; u_int32_t val; #if _BYTE_ORDER == _BIG_ENDIAN @@ -332,7 +346,7 @@ void ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; #if _BYTE_ORDER == _BIG_ENDIAN if (reg >= 0x4000 && reg < 0x5000) @@ -346,7 +360,7 @@ u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; u_int32_t val; #if _BYTE_ORDER == _BIG_ENDIAN @@ -398,37 +412,3 @@ ath_hal_memcpy(void *dst, const void *sr { return memcpy(dst, src, n); } - -/* - * Module glue. - */ - -static int -ath_hal_modevent(module_t mod, int type, void *unused) -{ - const char *sep; - int i; - - switch (type) { - case MOD_LOAD: - printf("ath_hal: %s (", ath_hal_version); - sep = ""; - for (i = 0; ath_hal_buildopts[i] != NULL; i++) { - printf("%s%s", sep, ath_hal_buildopts[i]); - sep = ", "; - } - printf(")\n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t ath_hal_mod = { - "ath_hal", - ath_hal_modevent, - 0 -}; -DECLARE_MODULE(ath_hal, ath_hal_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); -MODULE_VERSION(ath_hal, 1); Modified: stable/7/sys/dev/ath/ah_osdep.h ============================================================================== --- stable/7/sys/dev/ath/ah_osdep.h Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ah_osdep.h Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,13 +33,29 @@ /* * Atheros Hardware Access Layer (HAL) OS Dependent Definitions. */ +#include #include #include #include +#include #include /* + * Bus i/o type definitions. + */ +typedef void *HAL_SOFTC; +typedef bus_space_tag_t HAL_BUS_TAG; +typedef bus_space_handle_t HAL_BUS_HANDLE; + +/* + * Linker set writearounds for chip and RF backend registration. + */ +#define OS_DATA_SET(set, item) DATA_SET(set, item) +#define OS_SET_DECLARE(set, ptype) SET_DECLARE(set, ptype) +#define OS_SET_FOREACH(pvar, set) SET_FOREACH(pvar, set) + +/* * Delay n microseconds. */ extern void ath_hal_delay(int); Modified: stable/7/sys/dev/ath/ath_rate/amrr/amrr.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/amrr/amrr.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/amrr/amrr.c Thu Mar 12 03:09:11 2009 (r189720) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -78,7 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define AMRR_DEBUG #ifdef AMRR_DEBUG @@ -518,29 +517,3 @@ ath_rate_detach(struct ath_ratectrl *arc callout_drain(&asc->timer); free(asc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -amrr_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: version 0.1\n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t amrr_mod = { - "ath_rate", - amrr_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, amrr_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/ath_rate/onoe/onoe.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/onoe/onoe.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/onoe/onoe.c Thu Mar 12 03:09:11 2009 (r189720) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -66,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define ONOE_DEBUG #ifdef ONOE_DEBUG @@ -492,29 +491,3 @@ ath_rate_detach(struct ath_ratectrl *arc callout_drain(&osc->timer); free(osc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -onoe_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: \n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t onoe_mod = { - "ath_rate", - onoe_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, onoe_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/sample/sample.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/sample/sample.c Thu Mar 12 03:09:11 2009 (r189720) @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -74,7 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define SAMPLE_DEBUG #ifdef SAMPLE_DEBUG @@ -840,30 +839,3 @@ ath_rate_detach(struct ath_ratectrl *arc free(osc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -sample_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: version 1.2 \n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t sample_mod = { - "ath_rate", - sample_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, sample_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, ath_hal, 1, 1, 1); /* Atheros HAL */ -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/if_ath.c ============================================================================== --- stable/7/sys/dev/ath/if_ath.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_ath.c Thu Mar 12 03:09:11 2009 (r189720) @@ -77,13 +77,17 @@ __FBSDID("$FreeBSD$"); #endif #include -#include -#include /* XXX for softled */ +#include /* XXX for softled */ #ifdef ATH_TX99_DIAG #include #endif +/* + * We require a HAL w/ the changes for split tx/rx MIC. + */ +CTASSERT(HAL_ABI_VERSION > 0x06052200); + /* unaligned little endian access */ #define LE_READ_2(p) \ ((u_int16_t) \ @@ -378,7 +382,6 @@ ath_attach(u_int16_t devid, struct ath_s goto bad; } callout_init(&sc->sc_cal_ch, CALLOUT_MPSAFE); - callout_init(&sc->sc_dfs_ch, CALLOUT_MPSAFE); ATH_TXBUF_LOCK_INIT(sc); @@ -2250,14 +2253,13 @@ ath_key_update_end(struct ieee80211com * static u_int32_t ath_calcrxfilter(struct ath_softc *sc) { -#define RX_FILTER_PRESERVE (HAL_RX_FILTER_PHYERR | HAL_RX_FILTER_PHYRADAR) struct ieee80211com *ic = &sc->sc_ic; - struct ath_hal *ah = sc->sc_ah; struct ifnet *ifp = sc->sc_ifp; u_int32_t rfilt; - rfilt = (ath_hal_getrxfilter(ah) & RX_FILTER_PRESERVE) - | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; + rfilt = HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; + if (!sc->sc_needmib && !sc->sc_scanning) + rfilt |= HAL_RX_FILTER_PHYERR; if (ic->ic_opmode != IEEE80211_M_STA) rfilt |= HAL_RX_FILTER_PROBEREQ; if (ic->ic_opmode != IEEE80211_M_HOSTAP && @@ -4890,42 +4892,6 @@ ath_chan_change(struct ath_softc *sc, st } /* - * Poll for a channel clear indication; this is required - * for channels requiring DFS and not previously visited - * and/or with a recent radar detection. - */ -static void -ath_dfswait(void *arg) -{ - struct ath_softc *sc = arg; - struct ath_hal *ah = sc->sc_ah; - HAL_CHANNEL hchan; - - ath_hal_radar_wait(ah, &hchan); - DPRINTF(sc, ATH_DEBUG_DFS, "%s: radar_wait %u/%x/%x\n", - __func__, hchan.channel, hchan.channelFlags, hchan.privFlags); - - if (hchan.privFlags & CHANNEL_INTERFERENCE) { - if_printf(sc->sc_ifp, - "channel %u/0x%x/0x%x has interference\n", - hchan.channel, hchan.channelFlags, hchan.privFlags); - return; - } - if ((hchan.privFlags & CHANNEL_DFS) == 0) { - /* XXX should not happen */ - return; - } - if (hchan.privFlags & CHANNEL_DFS_CLEAR) { - sc->sc_curchan.privFlags |= CHANNEL_DFS_CLEAR; - sc->sc_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - if_printf(sc->sc_ifp, - "channel %u/0x%x/0x%x marked clear\n", - hchan.channel, hchan.channelFlags, hchan.privFlags); - } else - callout_reset(&sc->sc_dfs_ch, 2 * hz, ath_dfswait, sc); -} - -/* * Set/change channels. If the channel is really being changed, * it's done by reseting the chip. To accomplish this we must * first cleanup any pending DMA, then restart stuff after a la @@ -4996,25 +4962,6 @@ ath_chan_set(struct ath_softc *sc, struc ath_chan_change(sc, chan); /* - * Handle DFS required waiting period to determine - * if channel is clear of radar traffic. - */ - if (ic->ic_opmode == IEEE80211_M_HOSTAP) { -#define DFS_AND_NOT_CLEAR(_c) \ - (((_c)->privFlags & (CHANNEL_DFS | CHANNEL_DFS_CLEAR)) == CHANNEL_DFS) - if (DFS_AND_NOT_CLEAR(&sc->sc_curchan)) { - if_printf(sc->sc_ifp, - "wait for DFS clear channel signal\n"); - /* XXX stop sndq */ - sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE; - callout_reset(&sc->sc_dfs_ch, - 2 * hz, ath_dfswait, sc); - } else - callout_stop(&sc->sc_dfs_ch); -#undef DFS_NOT_CLEAR - } - - /* * Re-enable interrupts. */ ath_hal_intrset(ah, sc->sc_imask); @@ -5163,7 +5110,6 @@ ath_newstate(struct ieee80211com *ic, en ieee80211_state_name[nstate]); callout_stop(&sc->sc_cal_ch); - callout_stop(&sc->sc_dfs_ch); ath_hal_setledstate(ah, leds[nstate]); /* set LED */ if (nstate == IEEE80211_S_INIT) { Modified: stable/7/sys/dev/ath/if_ath_pci.c ============================================================================== --- stable/7/sys/dev/ath/if_ath_pci.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_ath_pci.c Thu Mar 12 03:09:11 2009 (r189720) @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -279,6 +278,4 @@ static devclass_t ath_devclass; DRIVER_MODULE(if_ath, pci, ath_pci_driver, ath_devclass, 0, 0); DRIVER_MODULE(if_ath, cardbus, ath_pci_driver, ath_devclass, 0, 0); MODULE_VERSION(if_ath, 1); -MODULE_DEPEND(if_ath, ath_hal, 1, 1, 1); /* Atheros HAL */ MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */ -MODULE_DEPEND(if_ath, ath_rate, 1, 1, 1); /* rate control algorithm */ Modified: stable/7/sys/dev/ath/if_athvar.h ============================================================================== --- stable/7/sys/dev/ath/if_athvar.h Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_athvar.h Thu Mar 12 03:09:11 2009 (r189720) @@ -35,8 +35,8 @@ #ifndef _DEV_ATH_ATHVAR_H #define _DEV_ATH_ATHVAR_H -#include -#include +#include +#include #include #include #include @@ -315,7 +315,6 @@ struct ath_softc { int sc_calinterval; /* current polling interval */ int sc_caltries; /* cals at current interval */ HAL_NODE_STATS sc_halstats; /* station-mode rssi stats */ - struct callout sc_dfs_ch; /* callout handle for dfs */ }; #define sc_tx_th u_tx_rt.th #define sc_rx_th u_rx_rt.th @@ -483,7 +482,7 @@ void ath_intr(void *); #define ath_hal_getregdomain(_ah, _prd) \ (ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK) #define ath_hal_setregdomain(_ah, _rd) \ - ((*(_ah)->ah_setRegulatoryDomain)((_ah), (_rd), NULL)) + ath_hal_setcapability(_ah, HAL_CAP_REG_DMN, 0, _rd, NULL) #define ath_hal_getcountrycode(_ah, _pcc) \ (*(_pcc) = (_ah)->ah_countryCode) #define ath_hal_hastkipsplit(_ah) \ @@ -618,7 +617,4 @@ void ath_intr(void *); #define ath_hal_gpiosetintr(_ah, _gpio, _b) \ ((*(_ah)->ah_gpioSetIntr)((_ah), (_gpio), (_b))) -#define ath_hal_radar_wait(_ah, _chan) \ - ((*(_ah)->ah_radarWait)((_ah), (_chan))) - #endif /* _DEV_ATH_ATHVAR_H */ Modified: stable/7/sys/i386/conf/GENERIC ============================================================================== --- stable/7/sys/i386/conf/GENERIC Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/i386/conf/GENERIC Thu Mar 12 03:09:11 2009 (r189720) @@ -255,6 +255,7 @@ device wlan_scan_sta # 802.11 STA mode device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. Modified: stable/7/sys/i386/conf/NOTES ============================================================================== --- stable/7/sys/i386/conf/NOTES Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/i386/conf/NOTES Thu Mar 12 03:09:11 2009 (r189720) @@ -680,6 +680,7 @@ device wpi device ath device ath_hal # Atheros HAL (includes binary component) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_amrr # AMRR rate control for ath driver #device ath_rate_onoe # Onoe rate control for ath driver device ath_rate_sample # SampleRate rate control for the ath driver Modified: stable/7/sys/modules/Makefile ============================================================================== --- stable/7/sys/modules/Makefile Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/modules/Makefile Thu Mar 12 03:09:11 2009 (r189720) @@ -28,11 +28,7 @@ SUBDIR= ${_3dfx} \ ${_arl} \ ${_asr} \ ata \ - ${_ath} \ - ${_ath_hal} \ - ${_ath_rate_amrr} \ - ${_ath_rate_onoe} \ - ${_ath_rate_sample} \ + ath \ aue \ ${_auxio} \ ${_awi} \ @@ -379,11 +375,6 @@ _aout= aout _apm= apm _ar= ar _arcnet= arcnet -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _awi= awi _bktr= bktr _cardbus= cardbus @@ -517,11 +508,6 @@ _acpi= acpi _agp= agp _an= an _arcmsr= arcmsr -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _cardbus= cardbus _cbb= cbb _cmx= cmx @@ -627,22 +613,12 @@ _xe= xe .if ${MACHINE_ARCH} == "powerpc" _an= an -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _bm= bm _nvram= powermac_nvram _smbfs= smbfs .endif .if ${MACHINE_ARCH} == "sparc64" -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _auxio= auxio _em= em _i2c= i2c Modified: stable/7/sys/modules/ath/Makefile ============================================================================== --- stable/7/sys/modules/ath/Makefile Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/modules/ath/Makefile Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting +# Copyright (c) 2002-2008 Sam Leffler, Errno Consulting *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Thu Mar 12 13:45:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F05D110656C5; Thu, 12 Mar 2009 13:45:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA1318FC22; Thu, 12 Mar 2009 13:45:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2CDjtHT031922; Thu, 12 Mar 2009 13:45:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2CDjt4P031917; Thu, 12 Mar 2009 13:45:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200903121345.n2CDjt4P031917@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 12 Mar 2009 13:45:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189740 - in stable/7: . lib/libc lib/libc/string lib/libc/sys sys sys/contrib/pf sys/dev/ath/ath_hal sys/dev/cxgb sys/kern sys/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 13:45:57 -0000 Author: kib Date: Thu Mar 12 13:45:55 2009 New Revision: 189740 URL: http://svn.freebsd.org/changeset/base/189740 Log: MFC r189283: Correct types of variables used to track amount of allocated SysV shared memory from int to size_t. Implement a workaround for current ABI not allowing to properly save size for and report more then 2GB sized segment of shared memory. This makes it possible to use > 2 GB shared memory segments on 64bit architectures. Please note the new BUGS section in shmctl(2) and UPDATING note for limitations of this temporal solution. MFC r189398: Systematically use vm_size_t to specify the size of the segment for VM KPI. Do not overload the local variable size in kern_shmat() due to vm_size_t change. Fix style bug by adding explicit comparision with 0. MFC r189399: Improve the grammar and wording in the changes to shmctl(2) manpage. Put an UPDATING entry and bump __FreeBSD_version for the change. Modified: stable/7/UPDATING stable/7/lib/libc/ (props changed) stable/7/lib/libc/string/ffsll.c (props changed) stable/7/lib/libc/string/flsll.c (props changed) stable/7/lib/libc/sys/shmctl.2 stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/sysv_shm.c stable/7/sys/sys/param.h stable/7/sys/sys/shm.h Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/UPDATING Thu Mar 12 13:45:55 2009 (r189740) @@ -9,6 +9,19 @@ Items affecting the ports and packages s portupgrade. 20090312: + A workaround is committed to allow the creation of System V shared + memory segment of size > 2 GB on the 64-bit architectures. + Due to a limitation of the existing ABI, the shm_segsz member + of the struct shmid_ds, returned by shmctl(IPC_STAT) call is + wrong for large segments. Note that limits must be explicitely + raised to allow such segments to be created. + + The management interface that is used by ipcs(1) has to be changed + in incompatible way. Rebuild the ipcs(1) utility with the new + headers after the update. Buildworld/installworld takes care + of this issue automatically. + +20090312: The open-source Atheros HAL has been merged from HEAD to STABLE. The kernel compile-time option AH_SUPPORT_AR5416 has been Modified: stable/7/lib/libc/sys/shmctl.2 ============================================================================== --- stable/7/lib/libc/sys/shmctl.2 Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/lib/libc/sys/shmctl.2 Thu Mar 12 13:45:55 2009 (r189740) @@ -133,6 +133,16 @@ the shared memory segment's owner or cre Permission denied due to mismatch between operation and mode of shared memory segment. .El +.Sh "BUGS" +The segment size has size_t type. +The shm_segsz member of the +.Vt shmid_ds +structure has type int, which is too short to represent the full range +of values for a segment size. +If shared memory limits are raised to allow segments with size > 2 GB +to be created, be aware that IPC_STAT call may return a truncated value +for shm_segsz. +.El .Sh "SEE ALSO" .Xr shmat 2 , .Xr shmdt 2 , Modified: stable/7/sys/kern/sysv_shm.c ============================================================================== --- stable/7/sys/kern/sysv_shm.c Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/kern/sysv_shm.c Thu Mar 12 13:45:55 2009 (r189740) @@ -121,7 +121,8 @@ static sy_call_t *shmcalls[] = { #define SHMSEG_ALLOCATED 0x0800 #define SHMSEG_WANTED 0x1000 -static int shm_last_free, shm_nused, shm_committed, shmalloced; +static int shm_last_free, shm_nused, shmalloced; +vm_size_t shm_committed; static struct shmid_kernel *shmsegs; struct shmmap_state { @@ -244,13 +245,13 @@ static void shm_deallocate_segment(shmseg) struct shmid_kernel *shmseg; { - size_t size; + vm_size_t size; GIANT_REQUIRED; vm_object_deallocate(shmseg->u.shm_internal); shmseg->u.shm_internal = NULL; - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); shm_committed -= btoc(size); shm_nused--; shmseg->u.shm_perm.mode = SHMSEG_FREE; @@ -264,13 +265,13 @@ shm_delete_mapping(struct vmspace *vm, s { struct shmid_kernel *shmseg; int segnum, result; - size_t size; + vm_size_t size; GIANT_REQUIRED; segnum = IPCID_TO_IX(shmmap_s->shmid); shmseg = &shmsegs[segnum]; - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); result = vm_map_remove(&vm->vm_map, shmmap_s->va, shmmap_s->va + size); if (result != KERN_SUCCESS) return (EINVAL); @@ -361,8 +362,8 @@ kern_shmat(td, shmid, shmaddr, shmflg) mtx_lock(&Giant); shmmap_s = p->p_vmspace->vm_shm; if (shmmap_s == NULL) { - size = shminfo.shmseg * sizeof(struct shmmap_state); - shmmap_s = malloc(size, M_SHM, M_WAITOK); + shmmap_s = malloc(shminfo.shmseg * sizeof(struct shmmap_state), + M_SHM, M_WAITOK); for (i = 0; i < shminfo.shmseg; i++) shmmap_s[i].shmid = -1; p->p_vmspace->vm_shm = shmmap_s; @@ -390,7 +391,7 @@ kern_shmat(td, shmid, shmaddr, shmflg) error = EMFILE; goto done2; } - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); #ifdef VM_PROT_READ_IS_EXEC prot = VM_PROT_READ | VM_PROT_EXECUTE; #else @@ -422,7 +423,8 @@ kern_shmat(td, shmid, shmaddr, shmflg) vm_object_reference(shmseg->u.shm_internal); rv = vm_map_find(&p->p_vmspace->vm_map, shmseg->u.shm_internal, - 0, &attach_va, size, (flags & MAP_FIXED)?0:1, prot, prot, 0); + 0, &attach_va, size, (flags & MAP_FIXED) ? VMFS_NO_SPACE : + VMFS_ANY_SPACE, prot, prot, 0); if (rv != KERN_SUCCESS) { vm_object_deallocate(shmseg->u.shm_internal); error = ENOMEM; @@ -705,7 +707,7 @@ shmget_existing(td, uap, mode, segnum) if (error != 0) return (error); #endif - if (uap->size && uap->size > shmseg->u.shm_segsz) + if (uap->size != 0 && uap->size > shmseg->shm_bsegsz) return (EINVAL); td->td_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->u.shm_perm); return (0); @@ -717,7 +719,8 @@ shmget_allocate_segment(td, uap, mode) struct shmget_args *uap; int mode; { - int i, segnum, shmid, size; + int i, segnum, shmid; + size_t size; struct ucred *cred = td->td_ucred; struct shmid_kernel *shmseg; vm_object_t shm_object; @@ -775,6 +778,7 @@ shmget_allocate_segment(td, uap, mode) shmseg->u.shm_perm.mode = (shmseg->u.shm_perm.mode & SHMSEG_WANTED) | (mode & ACCESSPERMS) | SHMSEG_ALLOCATED; shmseg->u.shm_segsz = uap->size; + shmseg->shm_bsegsz = uap->size; shmseg->u.shm_cpid = td->td_proc->p_pid; shmseg->u.shm_lpid = shmseg->u.shm_nattch = 0; shmseg->u.shm_atime = shmseg->u.shm_dtime = 0; Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/sys/param.h Thu Mar 12 13:45:55 2009 (r189740) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 701104 /* Master, propagated to newvers */ +#define __FreeBSD_version 701105 /* Master, propagated to newvers */ #ifndef LOCORE #include Modified: stable/7/sys/sys/shm.h ============================================================================== --- stable/7/sys/sys/shm.h Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/sys/shm.h Thu Mar 12 13:45:55 2009 (r189740) @@ -108,6 +108,7 @@ struct shminfo { struct shmid_kernel { struct shmid_ds u; struct label *label; /* MAC label */ + size_t shm_bsegsz; }; extern struct shminfo shminfo; From owner-svn-src-stable@FreeBSD.ORG Thu Mar 12 17:32:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41E96106568A; Thu, 12 Mar 2009 17:32:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1426A8FC25; Thu, 12 Mar 2009 17:32:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2CHW4PL036480; Thu, 12 Mar 2009 17:32:04 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2CHW4tg036479; Thu, 12 Mar 2009 17:32:04 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903121732.n2CHW4tg036479@svn.freebsd.org> From: John Baldwin Date: Thu, 12 Mar 2009 17:32:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189746 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 17:32:06 -0000 Author: jhb Date: Thu Mar 12 17:32:04 2009 New Revision: 189746 URL: http://svn.freebsd.org/changeset/base/189746 Log: MFC: Export hz, maxswzone, maxbcache, maxtsiz, dfldsiz, maxdsiz, dflssiz, maxssiz, and sgrowsiz via sysctl. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_param.c Modified: stable/7/sys/kern/subr_param.c ============================================================================== --- stable/7/sys/kern/subr_param.c Thu Mar 12 17:23:02 2009 (r189745) +++ stable/7/sys/kern/subr_param.c Thu Mar 12 17:32:04 2009 (r189746) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -85,6 +86,24 @@ u_long dflssiz; /* initial stack size u_long maxssiz; /* max stack size */ u_long sgrowsiz; /* amount to grow stack */ +SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, "ticks/second"); +SYSCTL_INT(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0, + "max swmeta KVA storage"); +SYSCTL_INT(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0, + "max buffer cache KVA storage"); +SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RDTUN, &maxtsiz, 0, + "max text size"); +SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RDTUN, &dfldsiz, 0, + "initial data size limit"); +SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RDTUN, &maxdsiz, 0, + "max data size"); +SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RDTUN, &dflssiz, 0, + "initial stack size limit"); +SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RDTUN, &maxssiz, 0, + "max stack size"); +SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RDTUN, &sgrowsiz, 0, + "amount to grow stack"); + /* * These have to be allocated somewhere; allocating * them here forces loader errors if this file is omitted From owner-svn-src-stable@FreeBSD.ORG Thu Mar 12 22:01:42 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A21D3106566C; Thu, 12 Mar 2009 22:01:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9020E8FC13; Thu, 12 Mar 2009 22:01:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2CM1gpe041774; Thu, 12 Mar 2009 22:01:42 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2CM1g8A041773; Thu, 12 Mar 2009 22:01:42 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903122201.n2CM1g8A041773@svn.freebsd.org> From: John Baldwin Date: Thu, 12 Mar 2009 22:01:42 +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: r189750 - stable/7/sys/vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 22:01:43 -0000 Author: jhb Date: Thu Mar 12 22:01:42 2009 New Revision: 189750 URL: http://svn.freebsd.org/changeset/base/189750 Log: Disable the vm_page_startup assertion for now. It always fails on platforms with superpages currently because the pages used by vm_reserv_startup() are incorrectly included in the 'npages' count. I haven't removed the assertion as I think this is a real bug, but the side effect is just that some memory is wasted on never-used vm_page structures. The assertion was removed from HEAD which is why the bug wasn't noticed there (and thus this is a direct commit to 7). Modified: stable/7/sys/vm/vm_page.c Modified: stable/7/sys/vm/vm_page.c ============================================================================== --- stable/7/sys/vm/vm_page.c Thu Mar 12 20:41:52 2009 (r189749) +++ stable/7/sys/vm/vm_page.c Thu Mar 12 22:01:42 2009 (r189750) @@ -363,15 +363,21 @@ vm_page_startup(vm_offset_t vaddr) vm_page_array[i].order = VM_NFREEORDER; vm_page_array_size = page_range; +#if 0 /* * This assertion tests the hypothesis that npages and total are * redundant. XXX + * + * XXX: This always fails if VM_NRESERVLEVEL > 0 because + * npages includes the memory for vm_reserv_startup() but + * page_range doesn't. */ page_range = 0; for (i = 0; phys_avail[i + 1] != 0; i += 2) page_range += atop(phys_avail[i + 1] - phys_avail[i]); KASSERT(page_range == npages, ("vm_page_startup: inconsistent page counts")); +#endif /* * Initialize the physical memory allocator. From owner-svn-src-stable@FreeBSD.ORG Fri Mar 13 01:28:11 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 360271065716; Fri, 13 Mar 2009 01:28:11 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 242D08FC26; Fri, 13 Mar 2009 01:28:11 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2D1SB3U045657; Fri, 13 Mar 2009 01:28:11 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2D1SBCC045656; Fri, 13 Mar 2009 01:28:11 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <200903130128.n2D1SBCC045656@svn.freebsd.org> From: "David E. O'Brien" Date: Fri, 13 Mar 2009 01:28:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189751 - stable/6/sys/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2009 01:28:12 -0000 Author: obrien Date: Fri Mar 13 01:28:10 2009 New Revision: 189751 URL: http://svn.freebsd.org/changeset/base/189751 Log: Catch up with the sx_object -> lock_object change. Modified: stable/6/sys/sys/lock.h Modified: stable/6/sys/sys/lock.h ============================================================================== --- stable/6/sys/sys/lock.h Thu Mar 12 22:01:42 2009 (r189750) +++ stable/6/sys/sys/lock.h Fri Mar 13 01:28:10 2009 (r189751) @@ -301,10 +301,10 @@ const char *witness_file(struct lock_obj LOCK_LINE) #define witness_check_shared_sx(sx) \ - WITNESS_CHECKORDER(&(sx)->sx_object, 0, LOCK_FILE, LOCK_LINE) + WITNESS_CHECKORDER(&(sx)->lock_object, 0, LOCK_FILE, LOCK_LINE) #define witness_check_exclusive_sx(sx) \ - WITNESS_CHECKORDER(&(sx)->sx_object, LOP_EXCLUSIVE, LOCK_FILE, \ + WITNESS_CHECKORDER(&(sx)->lock_object, LOP_EXCLUSIVE, LOCK_FILE, \ LOCK_LINE) #endif /* _KERNEL */ From owner-svn-src-stable@FreeBSD.ORG Fri Mar 13 10:52:23 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DD671065672; Fri, 13 Mar 2009 10:52:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6AB738FC13; Fri, 13 Mar 2009 10:52:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2DAqNBH061370; Fri, 13 Mar 2009 10:52:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2DAqN8n061365; Fri, 13 Mar 2009 10:52:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200903131052.n2DAqN8n061365@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 13 Mar 2009 10:52:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189766 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2009 10:52:24 -0000 Author: kib Date: Fri Mar 13 10:52:22 2009 New Revision: 189766 URL: http://svn.freebsd.org/changeset/base/189766 Log: MFC r189450: Extract the no_poll() and vop_nopoll() code into the common routine poll_no_poll(). Return a poll_no_poll() result from devfs_poll_f() when filedescriptor does not reference the live cdev, instead of ENXIO. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_vnops.c stable/7/sys/kern/kern_conf.c stable/7/sys/kern/sys_generic.c stable/7/sys/kern/vfs_default.c stable/7/sys/sys/systm.h Modified: stable/7/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_vnops.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/fs/devfs/devfs_vnops.c Fri Mar 13 10:52:22 2009 (r189766) @@ -973,7 +973,7 @@ devfs_poll_f(struct file *fp, int events fpop = td->td_fpop; error = devfs_fp_check(fp, &dev, &dsw); if (error) - return (error); + return (poll_no_poll(events)); error = dsw->d_poll(dev, events, td); td->td_fpop = fpop; dev_relthread(dev); Modified: stable/7/sys/kern/kern_conf.c ============================================================================== --- stable/7/sys/kern/kern_conf.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/kern_conf.c Fri Mar 13 10:52:22 2009 (r189766) @@ -313,18 +313,8 @@ no_strategy(struct bio *bp) static int no_poll(struct cdev *dev __unused, int events, struct thread *td __unused) { - /* - * Return true for read/write. If the user asked for something - * special, return POLLNVAL, so that clients have a way of - * determining reliably whether or not the extended - * functionality is present without hard-coding knowledge - * of specific filesystem implementations. - * Stay in sync with vop_nopoll(). - */ - if (events & ~POLLSTANDARD) - return (POLLNVAL); - return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); + return (poll_no_poll(events)); } #define no_dump (dumper_t *)enodev Modified: stable/7/sys/kern/sys_generic.c ============================================================================== --- stable/7/sys/kern/sys_generic.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/sys_generic.c Fri Mar 13 10:52:22 2009 (r189766) @@ -637,6 +637,22 @@ struct cv selwait; u_int nselcoll; /* Select collisions since boot */ SYSCTL_UINT(_kern, OID_AUTO, nselcoll, CTLFLAG_RD, &nselcoll, 0, ""); +int +poll_no_poll(int events) +{ + /* + * Return true for read/write. If the user asked for something + * special, return POLLNVAL, so that clients have a way of + * determining reliably whether or not the extended + * functionality is present without hard-coding knowledge + * of specific filesystem implementations. + */ + if (events & ~POLLSTANDARD) + return (POLLNVAL); + + return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); +} + #ifndef _SYS_SYSPROTO_H_ struct select_args { int nd; Modified: stable/7/sys/kern/vfs_default.c ============================================================================== --- stable/7/sys/kern/vfs_default.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/vfs_default.c Fri Mar 13 10:52:22 2009 (r189766) @@ -344,18 +344,8 @@ vop_nopoll(ap) struct thread *a_td; } */ *ap; { - /* - * Return true for read/write. If the user asked for something - * special, return POLLNVAL, so that clients have a way of - * determining reliably whether or not the extended - * functionality is present without hard-coding knowledge - * of specific filesystem implementations. - * Stay in sync with kern_conf.c::no_poll(). - */ - if (ap->a_events & ~POLLSTANDARD) - return (POLLNVAL); - return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); + return (poll_no_poll(ap->a_events)); } /* Modified: stable/7/sys/sys/systm.h ============================================================================== --- stable/7/sys/sys/systm.h Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/sys/systm.h Fri Mar 13 10:52:22 2009 (r189766) @@ -321,6 +321,8 @@ int uminor(dev_t dev); int umajor(dev_t dev); const char *devtoname(struct cdev *cdev); +int poll_no_poll(int events); + /* XXX: Should be void nanodelay(u_int nsec); */ void DELAY(int usec); From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 01:12:35 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 58E6A106564A; Sat, 14 Mar 2009 01:12:35 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 46E4A8FC08; Sat, 14 Mar 2009 01:12:35 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2E1CZ96077950; Sat, 14 Mar 2009 01:12:35 GMT (envelope-from bms@svn.freebsd.org) Received: (from bms@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2E1CZmM077949; Sat, 14 Mar 2009 01:12:35 GMT (envelope-from bms@svn.freebsd.org) Message-Id: <200903140112.n2E1CZmM077949@svn.freebsd.org> From: Bruce M Simpson Date: Sat, 14 Mar 2009 01:12: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: r189781 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 01:12:35 -0000 Author: bms Date: Sat Mar 14 01:12:35 2009 New Revision: 189781 URL: http://svn.freebsd.org/changeset/base/189781 Log: MFC rev: 189736 Ensure that the semaphore value is re-checked after sem_lock is re-acquired, after the condition variable is signalled. Early MFC, as the test case in the PR is fairly complete and the submitter also re-ran test case on -STABLE. It also bites Python fairly hard, which will otherwise try to use POSIX sems for its internal thread synchronization; this needs more in-depth testing. PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/127545 Reviewed by: attilio Modified: stable/7/sys/kern/uipc_sem.c Modified: stable/7/sys/kern/uipc_sem.c ============================================================================== --- stable/7/sys/kern/uipc_sem.c Sat Mar 14 00:33:08 2009 (r189780) +++ stable/7/sys/kern/uipc_sem.c Sat Mar 14 01:12:35 2009 (r189781) @@ -722,7 +722,7 @@ kern_sem_wait(struct thread *td, semid_t #endif DP(("kern_sem_wait value = %d, tryflag %d\n", ks->ks_value, tryflag)); vfs_timestamp(&ks->ks_atime); - if (ks->ks_value == 0) { + while (ks->ks_value == 0) { ks->ks_waiters++; if (tryflag != 0) error = EAGAIN; From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 01:25:01 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 91E0F106564A; Sat, 14 Mar 2009 01:25:01 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 62EC88FC08; Sat, 14 Mar 2009 01:25:01 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id EA3052EBBA8; Fri, 13 Mar 2009 21:25:00 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 13 Mar 2009 21:25:00 -0400 X-Sasl-enc: zxTSAs2hJxNrSIEfPDNIWKom4/nw6jgnQOmcq0UFOZsi 1236993900 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id 1B9E016290; Fri, 13 Mar 2009 21:25:00 -0400 (EDT) Message-ID: <49BB0769.6030200@incunabulum.net> Date: Sat, 14 Mar 2009 01:24:57 +0000 From: Bruce Simpson User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Bruce M Simpson References: <200903140112.n2E1CZmM077949@svn.freebsd.org> In-Reply-To: <200903140112.n2E1CZmM077949@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r189781 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 01:25:02 -0000 Bruce M Simpson wrote: > Early MFC, as the test case in the PR is fairly complete and the > submitter also re-ran test case on -STABLE. It also bites Python > fairly hard, which will otherwise try to use POSIX sems for its > internal thread synchronization; this needs more in-depth testing. > Note: FreeBSD's build of Python does NOT attempt to use POSIX sems by default, it will only do this if explicitly patched to do so. It defaults to using condvars + mutexes to build Python's internal thread locks. I'd encourage folk to try the patch which does this, I only posted the 'side-step' patch (i.e. use GNU Pth, needs to be explicitly enabled in OPTIONS) but the changes needed are in here too: http://people.freebsd.org/~bms/dump/python26-fbsd-pth.patch cheers BMS From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 02:05:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59315106564A; Sat, 14 Mar 2009 02:05:36 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 2A88D8FC0A; Sat, 14 Mar 2009 02:05:36 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id C3D382EDFB6; Fri, 13 Mar 2009 22:05:35 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 13 Mar 2009 22:05:35 -0400 X-Sasl-enc: SeRrQWZRXU9Nf91kfx9SCz6Vw+mWzB27ED51wgKVhTwf 1236996335 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id CDCE417D30; Fri, 13 Mar 2009 22:05:34 -0400 (EDT) Message-ID: <49BB10EC.9010705@incunabulum.net> Date: Sat, 14 Mar 2009 02:05:32 +0000 From: Bruce Simpson User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Bruce M Simpson References: <200903140112.n2E1CZmM077949@svn.freebsd.org> In-Reply-To: <200903140112.n2E1CZmM077949@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r189781 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 02:05:37 -0000 A big thanks to jhb@ for pushing much of the housekeeping around semaphores into the file descriptor layer, btw; without his major help, the fix for the logic wouldn't have been a one line diff. From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 08:34:46 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A7281065674; Sat, 14 Mar 2009 08:34:46 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC3FA8FC14; Sat, 14 Mar 2009 08:34:45 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2E8Yjnv086458; Sat, 14 Mar 2009 08:34:45 GMT (envelope-from bms@svn.freebsd.org) Received: (from bms@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2E8Yjn8086457; Sat, 14 Mar 2009 08:34:45 GMT (envelope-from bms@svn.freebsd.org) Message-Id: <200903140834.n2E8Yjn8086457@svn.freebsd.org> From: Bruce M Simpson Date: Sat, 14 Mar 2009 08:34:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189786 - stable/7/sys/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 08:34:46 -0000 Author: bms Date: Sat Mar 14 08:34:45 2009 New Revision: 189786 URL: http://svn.freebsd.org/changeset/base/189786 Log: Bump __FreeBSD_version to 701106 after the POSIX semaphore fix was committed. Modified: stable/7/sys/sys/param.h Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Sat Mar 14 08:28:02 2009 (r189785) +++ stable/7/sys/sys/param.h Sat Mar 14 08:34:45 2009 (r189786) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 701105 /* Master, propagated to newvers */ +#define __FreeBSD_version 701106 /* Master, propagated to newvers */ #ifndef LOCORE #include From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 12:33:35 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADD23106566C; Sat, 14 Mar 2009 12:33:35 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 7D50F8FC0C; Sat, 14 Mar 2009 12:33:35 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id D09A42EBA4C; Sat, 14 Mar 2009 08:33:34 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sat, 14 Mar 2009 08:33:34 -0400 X-Sasl-enc: Gw0RupQkXeN0Zeo59oU1Fdwa1n13YrOe1qnMZN+Mywc0 1237034014 Received: from anglepoise.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id DB818F11B; Sat, 14 Mar 2009 08:33:33 -0400 (EDT) Message-ID: <49BBA41B.9010308@incunabulum.net> Date: Sat, 14 Mar 2009 12:33:31 +0000 From: Bruce Simpson User-Agent: Thunderbird 2.0.0.19 (X11/20090125) MIME-Version: 1.0 To: Bruce M Simpson References: <200903140112.n2E1CZmM077949@svn.freebsd.org> <49BB0769.6030200@incunabulum.net> In-Reply-To: <49BB0769.6030200@incunabulum.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r189781 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 12:33:36 -0000 Bruce Simpson wrote: > > http://people.freebsd.org/~bms/dump/python26-fbsd-pth.patch This patch has been committed to the lang/python26 port with some fixups (thanks miwi). If you're a Python user, please try testing a Python port build with the SEM option selected so POSIX semaphores can receive more in-depth testing. thanks, BMS From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 14:02:53 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62935106564A; Sat, 14 Mar 2009 14:02:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 501208FC1F; Sat, 14 Mar 2009 14:02:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EE2rvP095141; Sat, 14 Mar 2009 14:02:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EE2ra6095140; Sat, 14 Mar 2009 14:02:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200903141402.n2EE2ra6095140@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Mar 2009 14:02:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189791 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 14:02:53 -0000 Author: kib Date: Sat Mar 14 14:02:53 2009 New Revision: 189791 URL: http://svn.freebsd.org/changeset/base/189791 Log: MFC r189706: Do not double-free the struct inode when insmntque failed. Default insmntque destructor reclaims the vnode, and ufs_reclaim frees the memory. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Mar 14 13:42:13 2009 (r189790) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Mar 14 14:02:53 2009 (r189791) @@ -1465,7 +1465,6 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags vp->v_vflag |= VV_FORCEINSMQ; error = insmntque(vp, mp); if (error != 0) { - uma_zfree(uma_inode, ip); *vpp = NULL; return (error); } From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 18:19:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E0A1106564A; Sat, 14 Mar 2009 18:19:51 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B6C98FC12; Sat, 14 Mar 2009 18:19:51 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EIJphe003730; Sat, 14 Mar 2009 18:19:51 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EIJouL003728; Sat, 14 Mar 2009 18:19:50 GMT (envelope-from das@svn.freebsd.org) Message-Id: <200903141819.n2EIJouL003728@svn.freebsd.org> From: David Schultz Date: Sat, 14 Mar 2009 18:19:50 +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: r189802 - in stable/7/lib/libc: . stdio X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 18:19:51 -0000 Author: das Date: Sat Mar 14 18:19:50 2009 New Revision: 189802 URL: http://svn.freebsd.org/changeset/base/189802 Log: Partial MFC of r189131: Make sure %zd treats negative arguments properly on 32-bit platforms. PR: 131880 Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdio/vfprintf.c stable/7/lib/libc/stdio/vfwprintf.c Modified: stable/7/lib/libc/stdio/vfprintf.c ============================================================================== --- stable/7/lib/libc/stdio/vfprintf.c Sat Mar 14 17:55:16 2009 (r189801) +++ stable/7/lib/libc/stdio/vfprintf.c Sat Mar 14 18:19:50 2009 (r189802) @@ -598,7 +598,7 @@ __vfprintf(FILE *fp, const char *fmt0, v #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT) #define SJARG() \ (flags&INTMAXT ? GETARG(intmax_t) : \ - flags&SIZET ? (intmax_t)GETARG(size_t) : \ + flags&SIZET ? (intmax_t)GETARG(ssize_t) : \ flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \ (intmax_t)GETARG(long long)) #define UJARG() \ Modified: stable/7/lib/libc/stdio/vfwprintf.c ============================================================================== --- stable/7/lib/libc/stdio/vfwprintf.c Sat Mar 14 17:55:16 2009 (r189801) +++ stable/7/lib/libc/stdio/vfwprintf.c Sat Mar 14 18:19:50 2009 (r189802) @@ -604,7 +604,7 @@ __vfwprintf(FILE *fp, const wchar_t *fmt #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT) #define SJARG() \ (flags&INTMAXT ? GETARG(intmax_t) : \ - flags&SIZET ? (intmax_t)GETARG(size_t) : \ + flags&SIZET ? (intmax_t)GETARG(ssize_t) : \ flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \ (intmax_t)GETARG(long long)) #define UJARG() \ From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 19:03:41 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D2271065755; Sat, 14 Mar 2009 19:03:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 545FA8FC1E; Sat, 14 Mar 2009 19:03:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EJ3f3O004947; Sat, 14 Mar 2009 19:03:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EJ3fZ6004945; Sat, 14 Mar 2009 19:03:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200903141903.n2EJ3fZ6004945@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Mar 2009 19:03:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189810 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 19:03:42 -0000 Author: kib Date: Sat Mar 14 19:03:40 2009 New Revision: 189810 URL: http://svn.freebsd.org/changeset/base/189810 Log: MFC r178585 (by pjd): Implement 'show mount' command in DDB. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c stable/7/sys/sys/mount.h Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:03:34 2009 (r189809) +++ stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:03:40 2009 (r189810) @@ -2712,6 +2712,158 @@ DB_SHOW_COMMAND(vnode, db_show_vnode) vp = (struct vnode *)addr; vn_printf(vp, "vnode "); } + +/* + * Show details about the given mount point. + */ +DB_SHOW_COMMAND(mount, db_show_mount) +{ + struct mount *mp; + struct statfs *sp; + struct vnode *vp; + char buf[512]; + u_int flags; + + if (!have_addr) { + /* No address given, print short info about all mount points. */ + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + db_printf("%p %s on %s (%s)\n", mp, + mp->mnt_stat.f_mntfromname, + mp->mnt_stat.f_mntonname, + mp->mnt_stat.f_fstypename); + } + db_printf("\nMore info: show mount \n"); + return; + } + + mp = (struct mount *)addr; + db_printf("%p %s on %s (%s)\n", mp, mp->mnt_stat.f_mntfromname, + mp->mnt_stat.f_mntonname, mp->mnt_stat.f_fstypename); + + buf[0] = '\0'; + flags = mp->mnt_flag; +#define MNT_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + MNT_FLAG(MNT_RDONLY); + MNT_FLAG(MNT_SYNCHRONOUS); + MNT_FLAG(MNT_NOEXEC); + MNT_FLAG(MNT_NOSUID); + MNT_FLAG(MNT_UNION); + MNT_FLAG(MNT_ASYNC); + MNT_FLAG(MNT_SUIDDIR); + MNT_FLAG(MNT_SOFTDEP); + MNT_FLAG(MNT_NOSYMFOLLOW); + MNT_FLAG(MNT_GJOURNAL); + MNT_FLAG(MNT_MULTILABEL); + MNT_FLAG(MNT_ACLS); + MNT_FLAG(MNT_NOATIME); + MNT_FLAG(MNT_NOCLUSTERR); + MNT_FLAG(MNT_NOCLUSTERW); + MNT_FLAG(MNT_EXRDONLY); + MNT_FLAG(MNT_EXPORTED); + MNT_FLAG(MNT_DEFEXPORTED); + MNT_FLAG(MNT_EXPORTANON); + MNT_FLAG(MNT_EXKERB); + MNT_FLAG(MNT_EXPUBLIC); + MNT_FLAG(MNT_LOCAL); + MNT_FLAG(MNT_QUOTA); + MNT_FLAG(MNT_ROOTFS); + MNT_FLAG(MNT_USER); + MNT_FLAG(MNT_IGNORE); + MNT_FLAG(MNT_UPDATE); + MNT_FLAG(MNT_DELEXPORT); + MNT_FLAG(MNT_RELOAD); + MNT_FLAG(MNT_FORCE); + MNT_FLAG(MNT_SNAPSHOT); + MNT_FLAG(MNT_BYFSID); +#undef MNT_FLAG + if (flags != 0) { + if (buf[0] != '\0') + strlcat(buf, ", ", sizeof(buf)); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "0x%08x", flags); + } + db_printf(" mnt_flag = %s\n", buf); + + buf[0] = '\0'; + flags = mp->mnt_kern_flag; +#define MNT_KERN_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 5, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + MNT_KERN_FLAG(MNTK_UNMOUNTF); + MNT_KERN_FLAG(MNTK_ASYNC); + MNT_KERN_FLAG(MNTK_SOFTDEP); + MNT_KERN_FLAG(MNTK_NOINSMNTQ); + MNT_KERN_FLAG(MNTK_UNMOUNT); + MNT_KERN_FLAG(MNTK_MWAIT); + MNT_KERN_FLAG(MNTK_SUSPEND); + MNT_KERN_FLAG(MNTK_SUSPEND2); + MNT_KERN_FLAG(MNTK_SUSPENDED); + MNT_KERN_FLAG(MNTK_MPSAFE); + MNT_KERN_FLAG(MNTK_NOKNOTE); + MNT_KERN_FLAG(MNTK_LOOKUP_SHARED); +#undef MNT_KERN_FLAG + if (flags != 0) { + if (buf[0] != '\0') + strlcat(buf, ", ", sizeof(buf)); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "0x%08x", flags); + } + db_printf(" mnt_kern_flag = %s\n", buf); + + sp = &mp->mnt_stat; + db_printf(" mnt_stat = { version=%u type=%u flags=0x%016jx " + "bsize=%ju iosize=%ju blocks=%ju bfree=%ju bavail=%jd files=%ju " + "ffree=%jd syncwrites=%ju asyncwrites=%ju syncreads=%ju " + "asyncreads=%ju namemax=%u owner=%u fsid=[%d, %d] }\n", + (u_int)sp->f_version, (u_int)sp->f_type, (uintmax_t)sp->f_flags, + (uintmax_t)sp->f_bsize, (uintmax_t)sp->f_iosize, + (uintmax_t)sp->f_blocks, (uintmax_t)sp->f_bfree, + (intmax_t)sp->f_bavail, (uintmax_t)sp->f_files, + (intmax_t)sp->f_ffree, (uintmax_t)sp->f_syncwrites, + (uintmax_t)sp->f_asyncwrites, (uintmax_t)sp->f_syncreads, + (uintmax_t)sp->f_asyncreads, (u_int)sp->f_namemax, + (u_int)sp->f_owner, (int)sp->f_fsid.val[0], (int)sp->f_fsid.val[1]); + + db_printf(" mnt_cred = { uid=%u ruid=%u", + (u_int)mp->mnt_cred->cr_uid, (u_int)mp->mnt_cred->cr_ruid); + if (mp->mnt_cred->cr_prison != NULL) + db_printf(", jail=%d", mp->mnt_cred->cr_prison->pr_id); + db_printf(" }\n"); + db_printf(" mnt_ref = %d\n", mp->mnt_ref); + db_printf(" mnt_gen = %d\n", mp->mnt_gen); + db_printf(" mnt_nvnodelistsize = %d\n", mp->mnt_nvnodelistsize); + db_printf(" mnt_writeopcount = %d\n", mp->mnt_writeopcount); + db_printf(" mnt_noasync = %u\n", mp->mnt_noasync); + db_printf(" mnt_maxsymlinklen = %d\n", mp->mnt_maxsymlinklen); + db_printf(" mnt_iosize_max = %d\n", mp->mnt_iosize_max); + db_printf(" mnt_hashseed = %u\n", mp->mnt_hashseed); + db_printf(" mnt_markercnt = %d\n", mp->mnt_markercnt); + db_printf(" mnt_holdcnt = %d\n", mp->mnt_holdcnt); + db_printf(" mnt_holdcntwaiters = %d\n", mp->mnt_holdcntwaiters); + db_printf(" mnt_secondary_writes = %d\n", mp->mnt_secondary_writes); + db_printf(" mnt_secondary_accwrites = %d\n", + mp->mnt_secondary_accwrites); + db_printf(" mnt_gjprovider = %s\n", + mp->mnt_gjprovider != NULL ? mp->mnt_gjprovider : "NULL"); + db_printf("\n"); + + TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { + if (vp->v_type != VMARKER) + vn_printf(vp, "vnode "); + } +} #endif /* DDB */ /* Modified: stable/7/sys/sys/mount.h ============================================================================== --- stable/7/sys/sys/mount.h Sat Mar 14 19:03:34 2009 (r189809) +++ stable/7/sys/sys/mount.h Sat Mar 14 19:03:40 2009 (r189810) @@ -41,6 +41,11 @@ #include #endif +/* + * NOTE: When changing statfs structure, mount structure, MNT_* flags or + * MNTK_* flags also update DDB show mount command in vfs_subr.c. + */ + typedef struct fsid { int32_t val[2]; } fsid_t; /* filesystem id type */ /* From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 19:35:13 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 664AF106567A; Sat, 14 Mar 2009 19:35:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53AA78FC2A; Sat, 14 Mar 2009 19:35:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EJZDnJ006078; Sat, 14 Mar 2009 19:35:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EJZDYT006077; Sat, 14 Mar 2009 19:35:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200903141935.n2EJZDYT006077@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Mar 2009 19:35:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189823 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 19:35:13 -0000 Author: kib Date: Sat Mar 14 19:35:13 2009 New Revision: 189823 URL: http://svn.freebsd.org/changeset/base/189823 Log: MFC r179093 (by pjd): Be more friendly for DDB pager. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:17:00 2009 (r189822) +++ stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:35:13 2009 (r189823) @@ -2731,6 +2731,8 @@ DB_SHOW_COMMAND(mount, db_show_mount) mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname, mp->mnt_stat.f_fstypename); + if (db_pager_quit) + break; } db_printf("\nMore info: show mount \n"); return; @@ -2860,8 +2862,11 @@ DB_SHOW_COMMAND(mount, db_show_mount) db_printf("\n"); TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { - if (vp->v_type != VMARKER) + if (vp->v_type != VMARKER) { vn_printf(vp, "vnode "); + if (db_pager_quit) + break; + } } } #endif /* DDB */ From owner-svn-src-stable@FreeBSD.ORG Sat Mar 14 21:03:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90DDF1065705; Sat, 14 Mar 2009 21:03:03 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7E0268FC16; Sat, 14 Mar 2009 21:03:03 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EL33Tf008080; Sat, 14 Mar 2009 21:03:03 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EL33ee008078; Sat, 14 Mar 2009 21:03:03 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200903142103.n2EL33ee008078@svn.freebsd.org> From: Max Laier Date: Sat, 14 Mar 2009 21:03:03 +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: r189831 - stable/7/usr.bin/du X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 21:03:04 -0000 Author: mlaier Date: Sat Mar 14 21:03:03 2009 New Revision: 189831 URL: http://svn.freebsd.org/changeset/base/189831 Log: MFC: - r184733, r184742 Add -A and -B options - r184654, r184656 style(9) changes - r173387, r173431 (by kevlo) Check return value for setenv() In effect sync head and releng/7. Modified: stable/7/usr.bin/du/ (props changed) stable/7/usr.bin/du/du.1 stable/7/usr.bin/du/du.c Modified: stable/7/usr.bin/du/du.1 ============================================================================== --- stable/7/usr.bin/du/du.1 Sat Mar 14 20:40:06 2009 (r189830) +++ stable/7/usr.bin/du/du.1 Sat Mar 14 21:03:03 2009 (r189831) @@ -32,7 +32,7 @@ .\" @(#)du.1 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd February 25, 2008 +.Dd November 6, 2008 .Dt DU 1 .Os .Sh NAME @@ -40,11 +40,12 @@ .Nd display disk usage statistics .Sh SYNOPSIS .Nm +.Op Fl A .Op Fl H | L | P .Op Fl a | s | d Ar depth .Op Fl c .Op Fl l -.Op Fl h | k | m +.Op Fl h | k | m | B Ar blocksize .Op Fl n .Op Fl x .Op Fl I Ar mask @@ -60,6 +61,25 @@ the current directory is displayed. .Pp The options are as follows: .Bl -tag -width indent +.It Fl A +Display the apparent size instead of the disk usage. +This can be helpful when operating on compressed volumes or sparse files. +.It Fl B Ar blocksize +Calculate block counts in +.Ar blocksize +byte blocks. +This is different from the +.Fl k, m +options or setting +.Ev BLOCKSIZE +and gives an estimate of how much space the examined file hierachy would +require on a filesystem with the given +.Ar blocksize . +Unless in +.Fl A +mode, +.Ar blocksize +is rounded up to the next multiple of 512. .It Fl H Symbolic links on the command line are followed, symbolic links in file hierarchies are not followed. @@ -136,14 +156,19 @@ followed is not counted or displayed. If the environment variable .Ev BLOCKSIZE is set, and the -.Fl k -option is not specified, the block counts will be displayed in units of that -size block. +.Fl k, m +or +.Fl h +options are not specified, the block counts will be displayed in units of +that block size. If .Ev BLOCKSIZE is not set, and the -.Fl k -option is not specified, the block counts will be displayed in 512-byte blocks. +.Fl k, m +or +.Fl h +options are not specified, the block counts will be displayed in 512-byte +blocks. .El .Sh SEE ALSO .Xr df 1 , Modified: stable/7/usr.bin/du/du.c ============================================================================== --- stable/7/usr.bin/du/du.c Sat Mar 14 20:40:06 2009 (r189830) +++ stable/7/usr.bin/du/du.c Sat Mar 14 21:03:03 2009 (r189831) @@ -73,20 +73,21 @@ struct ignentry { static int linkchk(FTSENT *); static void usage(void); -void prthumanval(int64_t); -void ignoreadd(const char *); -void ignoreclean(void); -int ignorep(FTSENT *); - -int nodumpflag = 0; +static void prthumanval(int64_t); +static void ignoreadd(const char *); +static void ignoreclean(void); +static int ignorep(FTSENT *); + +static int nodumpflag = 0; +static int Aflag; +static long blocksize, cblocksize; int main(int argc, char *argv[]) { FTS *fts; FTSENT *p; - off_t savednumber = 0; - long blocksize; + off_t savednumber, curblocks; int ftsoptions; int listall; int depth; @@ -98,75 +99,91 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = - lflag = 0; + lflag = Aflag = 0; save = argv; ftsoptions = 0; + savednumber = 0; + cblocksize = DEV_BSIZE; + blocksize = 0; depth = INT_MAX; SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HI:LPasd:chklmnrx")) != -1) + while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrx")) != -1) switch (ch) { - case 'H': - Hflag = 1; - break; - case 'I': - ignoreadd(optarg); - break; - case 'L': - if (Pflag) - usage(); - Lflag = 1; - break; - case 'P': - if (Lflag) - usage(); - Pflag = 1; - break; - case 'a': - aflag = 1; - break; - case 's': - sflag = 1; - break; - case 'd': - dflag = 1; - errno = 0; - depth = atoi(optarg); - if (errno == ERANGE || depth < 0) { - warnx("invalid argument to option d: %s", optarg); - usage(); - } - break; - case 'c': - cflag = 1; - break; - case 'h': - setenv("BLOCKSIZE", "512", 1); - hflag = 1; - break; - case 'k': - hflag = 0; - setenv("BLOCKSIZE", "1024", 1); - break; - case 'l': - lflag = 1; - break; - case 'm': - hflag = 0; - setenv("BLOCKSIZE", "1048576", 1); - break; - case 'n': - nodumpflag = 1; - break; - case 'r': /* Compatibility. */ - break; - case 'x': - ftsoptions |= FTS_XDEV; - break; - case '?': - default: + case 'A': + Aflag = 1; + break; + case 'B': + errno = 0; + cblocksize = atoi(optarg); + if (errno == ERANGE || cblocksize <= 0) { + warnx("invalid argument to option B: %s", + optarg); + usage(); + } + break; + case 'H': + Hflag = 1; + break; + case 'I': + ignoreadd(optarg); + break; + case 'L': + if (Pflag) + usage(); + Lflag = 1; + break; + case 'P': + if (Lflag) usage(); + Pflag = 1; + break; + case 'a': + aflag = 1; + break; + case 's': + sflag = 1; + break; + case 'd': + dflag = 1; + errno = 0; + depth = atoi(optarg); + if (errno == ERANGE || depth < 0) { + warnx("invalid argument to option d: %s", + optarg); + usage(); + } + break; + case 'c': + cflag = 1; + break; + case 'h': + hflag = 1; + break; + case 'k': + hflag = 0; + blocksize = 1024; + break; + case 'l': + lflag = 1; + break; + case 'm': + hflag = 0; + blocksize = 1048576; + break; + case 'n': + nodumpflag = 1; + break; + case 'r': /* Compatibility. */ + break; + case 'x': + ftsoptions |= FTS_XDEV; + break; + case '?': + default: + usage(); + /* NOTREACHED */ } argc -= optind; @@ -200,6 +217,9 @@ main(int argc, char *argv[]) if (Pflag) ftsoptions |= FTS_PHYSICAL; + if (!Aflag && (cblocksize % DEV_BSIZE) != 0) + cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE; + listall = 0; if (aflag) { @@ -218,8 +238,13 @@ main(int argc, char *argv[]) argv[1] = NULL; } - (void) getbsize(¬used, &blocksize); - blocksize /= 512; + if (blocksize == 0) + (void)getbsize(¬used, &blocksize); + + if (!Aflag) { + cblocksize /= DEV_BSIZE; + blocksize /= DEV_BSIZE; + } rval = 0; @@ -228,57 +253,65 @@ main(int argc, char *argv[]) while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { - case FTS_D: /* Ignore. */ - if (ignorep(p)) - fts_set(fts, p, FTS_SKIP); - break; - case FTS_DP: - if (ignorep(p)) - break; - - p->fts_parent->fts_bignum += - p->fts_bignum += p->fts_statp->st_blocks; - - if (p->fts_level <= depth) { - if (hflag) { - (void) prthumanval(howmany(p->fts_bignum, blocksize)); - (void) printf("\t%s\n", p->fts_path); - } else { - (void) printf("%jd\t%s\n", - (intmax_t)howmany(p->fts_bignum, blocksize), + case FTS_D: /* Ignore. */ + if (ignorep(p)) + fts_set(fts, p, FTS_SKIP); + break; + case FTS_DP: + if (ignorep(p)) + break; + + curblocks = Aflag ? + howmany(p->fts_statp->st_size, cblocksize) : + howmany(p->fts_statp->st_blocks, cblocksize); + p->fts_parent->fts_bignum += p->fts_bignum += + curblocks; + + if (p->fts_level <= depth) { + if (hflag) { + prthumanval(p->fts_bignum); + (void)printf("\t%s\n", p->fts_path); + } else { + (void)printf("%jd\t%s\n", + (intmax_t)howmany(p->fts_bignum * + cblocksize, blocksize), p->fts_path); - } } - break; - case FTS_DC: /* Ignore. */ - break; - case FTS_DNR: /* Warn, continue. */ - case FTS_ERR: - case FTS_NS: - warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); - rval = 1; - break; - default: - if (ignorep(p)) - break; - - if (lflag == 0 && - p->fts_statp->st_nlink > 1 && linkchk(p)) - break; - - if (listall || p->fts_level == 0) { - if (hflag) { - (void) prthumanval(howmany(p->fts_statp->st_blocks, - blocksize)); - (void) printf("\t%s\n", p->fts_path); - } else { - (void) printf("%jd\t%s\n", - (intmax_t)howmany(p->fts_statp->st_blocks, blocksize), - p->fts_path); - } + } + break; + case FTS_DC: /* Ignore. */ + break; + case FTS_DNR: /* Warn, continue. */ + case FTS_ERR: + case FTS_NS: + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + rval = 1; + break; + default: + if (ignorep(p)) + break; + + if (lflag == 0 && p->fts_statp->st_nlink > 1 && + linkchk(p)) + break; + + curblocks = Aflag ? + howmany(p->fts_statp->st_size, cblocksize) : + howmany(p->fts_statp->st_blocks, cblocksize); + + if (listall || p->fts_level == 0) { + if (hflag) { + prthumanval(curblocks); + (void)printf("\t%s\n", p->fts_path); + } else { + (void)printf("%jd\t%s\n", + (intmax_t)howmany(curblocks * + cblocksize, blocksize), + p->fts_path); } + } - p->fts_parent->fts_bignum += p->fts_statp->st_blocks; + p->fts_parent->fts_bignum += curblocks; } savednumber = p->fts_parent->fts_bignum; } @@ -288,10 +321,11 @@ main(int argc, char *argv[]) if (cflag) { if (hflag) { - (void) prthumanval(howmany(savednumber, blocksize)); - (void) printf("\ttotal\n"); + prthumanval(savednumber); + (void)printf("\ttotal\n"); } else { - (void) printf("%jd\ttotal\n", (intmax_t)howmany(savednumber, blocksize)); + (void)printf("%jd\ttotal\n", (intmax_t)howmany( + savednumber * cblocksize, blocksize)); } } @@ -344,7 +378,8 @@ linkchk(FTSENT *p) free_list = le->next; free(le); } - new_buckets = malloc(new_size * sizeof(new_buckets[0])); + new_buckets = malloc(new_size * + sizeof(new_buckets[0])); } if (new_buckets == NULL) { @@ -432,12 +467,14 @@ linkchk(FTSENT *p) return (0); } -void +static void prthumanval(int64_t bytes) { char buf[5]; - bytes *= DEV_BSIZE; + bytes *= cblocksize; + if (!Aflag) + bytes *= DEV_BSIZE; humanize_number(buf, sizeof(buf), bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); @@ -449,12 +486,13 @@ static void usage(void) { (void)fprintf(stderr, - "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] " - "[-l] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n"); + "usage: du [-A] [-H | -L | -P] [-a | -s | -d depth] [-c] " + "[-l] [-h | -k | -m | -B bsize] [-n] [-x] [-I mask] " + "[file ...]\n"); exit(EX_USAGE); } -void +static void ignoreadd(const char *mask) { struct ignentry *ign; @@ -468,7 +506,7 @@ ignoreadd(const char *mask) SLIST_INSERT_HEAD(&ignores, ign, next); } -void +static void ignoreclean(void) { struct ignentry *ign; @@ -481,7 +519,7 @@ ignoreclean(void) } } -int +static int ignorep(FTSENT *ent) { struct ignentry *ign;