From owner-cvs-all@FreeBSD.ORG Mon Apr 14 01:55:03 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD03B37B401; Mon, 14 Apr 2003 01:55:03 -0700 (PDT) Received: from is2.mh.itc.u-tokyo.ac.jp (is2.mh.itc.u-tokyo.ac.jp [133.11.205.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 941DE43FA3; Mon, 14 Apr 2003 01:55:01 -0700 (PDT) (envelope-from simokawa@sat.t.u-tokyo.ac.jp) Received: from is2.mh.itc.u-tokyo.ac.jp (is2.mh.itc.u-tokyo.ac.jp [127.0.0.1]) by is2.mh.itc.u-tokyo.ac.jp (Postfix) with ESMTP id B030937816D; Mon, 14 Apr 2003 17:54:58 +0900 (JST) Received: from mailhosting.itc.u-tokyo.ac.jp (IDENT:mirapoint@mailhosting.itc.u-tokyo.ac.jp [133.11.205.3]) h3E8swxi013982; Mon, 14 Apr 2003 17:54:58 +0900 Received: from ett.sat.t.u-tokyo.ac.jp (ett.sat.t.u-tokyo.ac.jp [133.11.135.3])2.9.3.2) with ESMTP id AIJ15020; Mon, 14 Apr 2003 17:54:57 +0900 (JST) Date: Mon, 14 Apr 2003 17:54:58 +0900 Message-ID: From: Hidetoshi Shimokawa To: Jake Burkholder In-Reply-To: <20030414073329.GC97094@locore.ca> References: <200304140419.h3E4Jgwi070671@repoman.freebsd.org> <20030414073329.GC97094@locore.ca> User-Agent: Wanderlust/2.11.0 (Wonderwall) REMI/1.14.3 (Matsudai) FLIM/1.14.3 (=?ISO-8859-1?Q?Unebigory=F2mae?=) APEL/10.3 MULE XEmacs/21.4 (patch 8) (Honest Recruiter) (i386--freebsd) X-Face: OE([KxWyJI0r[R~S/>7ia}SJ)i%a,$-9%7{*yihQk|]gl}2p#"oXmX/fT}Bn7: #j7i14gu$jgR\S*&C3R/pJX cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org cc: cvs-src@FreeBSD.org Subject: Re: cvs commit: src/sys/i386/i386 busdma_machdep.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2003 08:55:04 -0000 At Mon, 14 Apr 2003 03:33:29 -0400, Jake Burkholder wrote: > > Apparently, On Sun, Apr 13, 2003 at 09:19:42PM -0700, > Hidetoshi Shimokawa said words to the effect of; > > > simokawa 2003/04/13 21:19:42 PDT > > > > FreeBSD src repository > > > > Modified files: > > sys/i386/i386 busdma_machdep.c > > Log: > > * Use _bus_dmamap_load_buffer() and respect maxsegsz in bus_dmamap_load(). > > Ignoring maxsegsz may lead to fatal data corruption for some devices. > > ex. SBP-2/FireWire > > Hmm. _bus_dmamap_load_buffer doesn't handle delayed loads due to lack > of resources like bus_dmamap_load does (did). I think you will need to > respect BUS_DMA_WAITOK/BUS_DMA_NOWAIT in the flags argument to > _bus_dmamap_load_buffer, and pass BUS_DMA_WAITOK in bus_dmamap_load and > BUS_DMA_NOWAIT in other cases. If _bus_dmamap_load_buffer runs out of > resources it should return EINPROGRESS and queue the request if > BUS_DMA_WAITOK is specified, or return ENOMEM if BUS_DMA_NOWAIT is specified. You are right. How about this patch? /\ Hidetoshi Shimokawa \/ simokawa@sat.t.u-tokyo.ac.jp PGP public key: http://www.sat.t.u-tokyo.ac.jp/~simokawa/pgp.html Index: busdma_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/busdma_machdep.c,v retrieving revision 1.41 diff -u -r1.41 busdma_machdep.c --- busdma_machdep.c 14 Apr 2003 04:19:42 -0000 1.41 +++ busdma_machdep.c 14 Apr 2003 08:52:48 -0000 @@ -464,9 +464,22 @@ /* Reserve Necessary Bounce Pages */ if (map->pagesneeded != 0) { mtx_lock(&bounce_lock); - if (reserve_bounce_pages(dmat, map, 0) != 0) { - mtx_unlock(&bounce_lock); - return (ENOMEM); + if (flags & BUS_DMA_NOWAIT) { + if (reserve_bounce_pages(dmat, map, 0) != 0) { + mtx_unlock(&bounce_lock); + return (ENOMEM); + } + } else { + if (reserve_bounce_pages(dmat, map, 1) != 0) { + /* Queue us for resources */ + map->dmat = dmat; + map->buf = buf; + map->buflen = buflen; + STAILQ_INSERT_TAIL(&bounce_map_waitinglist, + map, links); + mtx_unlock(&bounce_lock); + return (EINPROGRESS); + } } mtx_unlock(&bounce_lock); } @@ -556,9 +569,16 @@ bus_addr_t lastaddr = 0; int error, nsegs = 0; + flags |= BUS_DMA_WAITOK; + map->callback = callback; + map->callback_arg = callback_arg; + error = _bus_dmamap_load_buffer(dmat, map, dm_segments, buf, buflen, NULL, flags, &lastaddr, &nsegs, 1); + if (error == EINPROGRESS) + return error; + if (error) (*callback)(callback_arg, dm_segments, 0, error); else @@ -587,6 +607,7 @@ KASSERT(m0->m_flags & M_PKTHDR, ("bus_dmamap_load_mbuf: no packet header")); + flags |= BUS_DMA_NOWAIT; nsegs = 0; error = 0; if (m0->m_pkthdr.len <= dmat->maxsize) { @@ -638,6 +659,7 @@ struct iovec *iov; struct thread *td = NULL; + flags |= BUS_DMA_NOWAIT; resid = uio->uio_resid; iov = uio->uio_iov;