Re: API change for bus_dma
From: Scott Long (scott_long_at_btc.adaptec.com)
Date: 06/27/03
- Previous message: Andrew Gallatin: "Re: API change for bus_dma"
- In reply to: Andrew Gallatin: "Re: API change for bus_dma"
- Next in thread: Andrew Gallatin: "Re: API change for bus_dma"
- Reply: Andrew Gallatin: "Re: API change for bus_dma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 27 Jun 2003 13:46:53 -0600 To: Andrew Gallatin <gallatin@cs.duke.edu>
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
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
- Previous message: Andrew Gallatin: "Re: API change for bus_dma"
- In reply to: Andrew Gallatin: "Re: API change for bus_dma"
- Next in thread: Andrew Gallatin: "Re: API change for bus_dma"
- Reply: Andrew Gallatin: "Re: API change for bus_dma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|