Date: Fri, 27 Jun 2003 13:46:53 -0600 From: Scott Long <scott_long@btc.adaptec.com> To: Andrew Gallatin <gallatin@cs.duke.edu> Cc: freebsd-arch@freebsd.org Subject: Re: API change for bus_dma Message-ID: <3EFC9F2D.6020908@btc.adaptec.com> In-Reply-To: <16124.39930.142492.356163@grasshopper.cs.duke.edu> References: <3EF3C12F.9060303@btc.adaptec.com> <16124.39930.142492.356163@grasshopper.cs.duke.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Andrew Gallatin wrote: > Scott Long writes: > > All, > > > > As I work towards locking down storage drivers, I'm also preening their > > use of busdma. A common theme among them is a misuse of > > bus_dmamap_load() and the associated callback mechanism. For most, the > > Why not just add a way to avoid deferring the callback entirely? I'm > talking about something like Solaris' ability to pass DDI_DMA_DONTWAIT > as the callback function to ddi_dma_buf_bind_handle(). > As you hinted below, BUS_DMA_NOWAIT does what you want. It will return ENOMEM to the caller if the bounce buffers cannot be pre-allocated during bus_dmamap_load(). > My desire is to know immediately whether the DMA mapping failed. If > it failed, that's OK with me. Since my driver locks users memory and maps > it for DMA for a potentially unbounded amount of time, I want to > know about a failure right away, not pile up requests that will never > be satisfied. bus_dmamap_load() is designed to always return immediately with either sucess (meaning that the callback was called), or some sort of error code. A return of EINPROGRESS means that bouncing was required but bounce buffers were not available so the callback was defered. There is a flaw in that bus_dmamap_load() treats every request individually. If a request comes in that has to be deferred, and a second request comes in that doesn't need to be deferred, it's likely that the second request will be serviced before the first. SCSI drivers (that check EINPROGRESS correctly) get around this by telling CAM to freeze the queue until the deferred request is serviced. The better solution is probably for bus_dmamap_load() to defer any new requests while prior ones are still pending. Scott
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3EFC9F2D.6020908>