From owner-svn-src-head@FreeBSD.ORG Tue Aug 21 19:39:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1354D106564A; Tue, 21 Aug 2012 19:39:10 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D8AB48FC12; Tue, 21 Aug 2012 19:39:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7LJd9Nc093496; Tue, 21 Aug 2012 19:39:09 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7LJd96B093494; Tue, 21 Aug 2012 19:39:09 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201208211939.q7LJd96B093494@svn.freebsd.org> From: Navdeep Parhar Date: Tue, 21 Aug 2012 19:39:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239527 - head/sys/dev/cxgbe/tom X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2012 19:39:10 -0000 Author: np Date: Tue Aug 21 19:39:09 2012 New Revision: 239527 URL: http://svn.freebsd.org/changeset/base/239527 Log: Cannot hold a mutex around vm_fault_quick_hold_pages, so don't. Tweak some comments while here. Modified: head/sys/dev/cxgbe/tom/t4_ddp.c Modified: head/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_ddp.c Tue Aug 21 19:32:55 2012 (r239526) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Tue Aug 21 19:39:09 2012 (r239527) @@ -769,7 +769,9 @@ write_page_pods(struct adapter *sc, stru } /* - * Reuse, or allocate (and program the page pods for) a new DDP buffer. + * Reuse, or allocate (and program the page pods for) a new DDP buffer. The + * "pages" array is handed over to this function and should not be used in any + * way by the caller after that. */ static int select_ddp_buffer(struct adapter *sc, struct toepcb *toep, vm_page_t *pages, @@ -843,13 +845,6 @@ unwire_ddp_buffer(struct ddp_buffer *db) } } -static inline void -unhold_ddp_buffer(struct ddp_buffer *db) -{ - - vm_page_unhold_pages(db->pages, db->npages); -} - static int handle_ddp(struct socket *so, struct uio *uio, int flags, int error) { @@ -883,15 +878,24 @@ handle_ddp(struct socket *so, struct uio * Fault in and then hold the pages of the uio buffers. We'll wire them * a bit later if everything else works out. */ - if (hold_uio(uio, &pages, &npages) != 0) + SOCKBUF_UNLOCK(sb); + if (hold_uio(uio, &pages, &npages) != 0) { + SOCKBUF_LOCK(sb); goto no_ddp; + } + SOCKBUF_LOCK(sb); + if (__predict_false(so->so_error || sb->sb_state & SBS_CANTRCVMORE)) { + vm_page_unhold_pages(pages, npages); + free(pages, M_CXGBE); + goto no_ddp; + } /* * Figure out which one of the two DDP buffers to use this time. */ db_idx = select_ddp_buffer(sc, toep, pages, npages, (uintptr_t)uio->uio_iov->iov_base & PAGE_MASK, uio->uio_resid); - pages = NULL; /* pages either in use elsewhere or unheld + freed */ + pages = NULL; /* handed off to select_ddp_buffer */ if (db_idx < 0) goto no_ddp; db = toep->db[db_idx]; @@ -904,11 +908,17 @@ handle_ddp(struct socket *so, struct uio ddp_flags = select_ddp_flags(so, flags, db_idx); wr = mk_update_tcb_for_ddp(sc, toep, db_idx, sb->sb_cc, ddp_flags); if (wr == NULL) { - unhold_ddp_buffer(db); + /* + * Just unhold the pages. The DDP buffer's software state is + * left as-is in the toep. The page pods were written + * successfully and we may have an opportunity to use it in the + * future. + */ + vm_page_unhold_pages(db->pages, db->npages); goto no_ddp; } - /* Wire the pages and give the chip the go-ahead. */ + /* Wire (and then unhold) the pages, and give the chip the go-ahead. */ wire_ddp_buffer(db); t4_wrq_tx(sc, wr); sb->sb_flags &= ~SB_DDP_INDICATE;