Bug 53751

Summary: bus_dma(9) incorrectly documents BUS_DMA_ALLOCNOW
Product: Documentation Reporter: Hartmut Brandt <harti>
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: doc, mhorne, pauamma
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Hartmut Brandt freebsd_committer freebsd_triage 2003-06-26 09:30:09 UTC
The explanaition of the BUS_DMA_ALLOCNOW flag to bus_dma_tag_create is
correct only if that tag is used for just one map. This is because
bus_dma_tag_create tries to allocate bounce pages based only on the size of
the desired mapping. It cannot now how many maps will be created using that
tag. One example where it doesn't work are network drivers which will use on
tag to map all the receive or transmit buffers. Each mapped buffer may require
its own bounce buffer, but tag_create has allocated only space for one map.
Therefor bus_dmamap_load_mbuf will return either EINPROGRESS (if called without
BUS_DMA_NOWAIT) or ENOMEM when it fails to allocate bounce buffers.

Fix: 

Either document a short version of the above or completly overhaul the bus dma
stuff :-)
How-To-Repeat: 
Look at the code in i386/i386/busdma_machdep.c
Comment 1 Bruce M Simpson freebsd_committer freebsd_triage 2004-07-03 07:42:17 UTC
Responsible Changed
From-To: freebsd-doc->hmp

This is hmp's manor
Comment 2 gnats freebsd_committer freebsd_triage 2007-07-31 06:52:32 UTC
Responsible Changed
From-To: hmp->freebsd-doc
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:05 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Pau Amma 2021-01-17 00:18:41 UTC
Is this still applicable? That description now reads:

                              BUS_DMA_ALLOCNOW      Pre-allocate enough
                                                    resources to handle at
                                                    least one map load
                                                    operation on this tag.  If
                                                    sufficient resources are
                                                    not available, ENOMEM is
                                                    returned.  This should not
                                                    be used for tags that only
                                                    describe buffers that will
                                                    be allocated with
                                                    bus_dmamem_alloc().  Also,
                                                    due to resource sharing
                                                    with other tags, this flag
                                                    does not guarantee that
                                                    resources will be
                                                    allocated or reserved
                                                    exclusively for this tag.
                                                    It should be treated only
                                                    as a minor optimization.
Comment 5 Mitchell Horne freebsd_committer freebsd_triage 2022-10-19 14:53:28 UTC
It looks like this was fixed by scottl@ in 0f3a007844a7/SVN r136763, but he was unaware of this PR.

I did a quick reading of the relevant code, and the current description appears accurate. Thanks all, closing this.