Sync more things with other backends.

This commit is contained in:
Maxime Henrion 2003-07-01 19:16:48 +00:00
parent 73f0b07961
commit 331e012396
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117136
2 changed files with 18 additions and 24 deletions

View File

@ -22,10 +22,11 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
@ -76,6 +77,7 @@ struct bounce_page {
int busdma_swi_pending;
static struct mtx bounce_lock;
static STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
static int free_bpages;
static int reserved_bpages;
@ -102,15 +104,12 @@ static struct bus_dmamap nobounce_dmamap;
static void init_bounce_pages(void *dummy);
static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages);
static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
int commit);
int commit);
static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
vm_offset_t vaddr, bus_size_t size);
static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
/* To protect all the the bounce pages related lists and data. */
static struct mtx bounce_lock;
/*
* Return true if a match is made.
*
@ -372,7 +371,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
int
bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
{
if (map != NULL) {
if (map != NULL && map != &nobounce_dmamap) {
if (STAILQ_FIRST(&map->bpages) != NULL)
return (EBUSY);
free(map, M_DEVBUF);
@ -509,7 +508,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat,
map->buf = buf;
map->buflen = buflen;
STAILQ_INSERT_TAIL(&bounce_map_waitinglist,
map, links);
map, links);
mtx_unlock(&bounce_lock);
return (EINPROGRESS);
}
@ -639,8 +638,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
#endif
int nsegs, error;
KASSERT(m0->m_flags & M_PKTHDR,
("bus_dmamap_load_mbuf: no packet header"));
M_ASSERTPKTHDR(m0);
flags |= BUS_DMA_NOWAIT;
nsegs = 0;

View File

@ -22,7 +22,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <sys/cdefs.h>
@ -78,6 +77,7 @@ struct bounce_page {
int busdma_swi_pending;
static struct mtx bounce_lock;
static STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
static int free_bpages;
static int reserved_bpages;
@ -104,15 +104,12 @@ static struct bus_dmamap nobounce_dmamap;
static void init_bounce_pages(void *dummy);
static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages);
static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
int commit);
int commit);
static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
vm_offset_t vaddr, bus_size_t size);
static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
/* To protect all the the bounce pages related lists and data. */
static struct mtx bounce_lock;
/*
* Return true if a match is made.
*
@ -374,7 +371,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
int
bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
{
if (map != NULL) {
if (map != NULL && map != &nobounce_dmamap) {
if (STAILQ_FIRST(&map->bpages) != NULL)
return (EBUSY);
free(map, M_DEVBUF);
@ -511,7 +508,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat,
map->buf = buf;
map->buflen = buflen;
STAILQ_INSERT_TAIL(&bounce_map_waitinglist,
map, links);
map, links);
mtx_unlock(&bounce_lock);
return (EINPROGRESS);
}
@ -641,8 +638,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
#endif
int nsegs, error;
KASSERT(m0->m_flags & M_PKTHDR,
("bus_dmamap_load_mbuf: no packet header"));
M_ASSERTPKTHDR(m0);
flags |= BUS_DMA_NOWAIT;
nsegs = 0;
@ -920,7 +916,7 @@ busdma_swi(void)
while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) {
STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links);
mtx_unlock(&bounce_lock);
dmat = (map)->dmat;
dmat = map->dmat;
(dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_LOCK);
bus_dmamap_load(map->dmat, map, map->buf, map->buflen,
map->callback, map->callback_arg, /*flags*/0);