Re: API change for bus_dma

From: Scott Long (scott_long_at_btc.adaptec.com)
Date: 06/27/03

  • Next message: Andrew Gallatin: "Re: API change for bus_dma"
    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"


  • Next message: Andrew Gallatin: "Re: API change for bus_dma"

    Relevant Pages

    • Re: [PATCH] block: fix residual byte count handling
      ... buffer stuff affected only libata but seems it doesn't ...). ... is because before moving alignment and padding to block layer, ... For drivers which don't require data size adjustment from block layer, ... For drivers which do require request size adjustments, ...
      (Linux-Kernel)
    • Re: HttpModules - Webservices
      ... with a native debugger. ... >Hi Scott, ... >before it hangs. ... >>>HttpRequest request) ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: SBS2000 server BSOD when local machine uses Citrix Client
      ... The links you posted often had specific drivers attached to the errors. ... MS debugging tools on a production server? ... > pageable memory at a process internal request level that was too ... A suggestion would be to contact Microsoft Customer Support Services ...
      (microsoft.public.windows.server.sbs)
    • Re: [PATCH] block: fix residual byte count handling
      ... buffer stuff affected only libata but seems it doesn't ...). ... is because before moving alignment and padding to block layer, ... I think that currently the biggest problem is that drivers which don't ... For drivers which do require request size adjustments, ...
      (Linux-Kernel)
    • Re: kern/112119: system hangs when starts k3b on RELENG_6
      ... This is probably the command that is ... Good catch Scott! ... I just installed this patch on my i386 system and I can now start K3B ... REQUEST asc=0x24 ascq=0x00 ...
      (freebsd-stable)