diff options
author | yongari <yongari@FreeBSD.org> | 2010-07-19 23:41:45 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2010-07-19 23:41:45 +0000 |
commit | 635930644d40205c22fb99efd6b46f15a419e0a1 (patch) | |
tree | 7f75b0b12d9b23ba3efd6b461c2ed9333497bc59 /sys/dev/bce | |
parent | 583fcb4c198241097addb794704182a5ed9ea982 (diff) | |
download | FreeBSD-src-635930644d40205c22fb99efd6b46f15a419e0a1.zip FreeBSD-src-635930644d40205c22fb99efd6b46f15a419e0a1.tar.gz |
Specify BUS_DMA_ZERO flag to bus_dmamem_alloc(9) and remove bzero()
calls. Also add BUS_DMA_COHERENT flag to bus_dmamem_alloc(9) to
take advantage of efficient synchronization for architectures that
support that feature.
Reviewed by: davidch
Diffstat (limited to 'sys/dev/bce')
-rw-r--r-- | sys/dev/bce/if_bce.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index 37ae578..68467e1 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -3172,15 +3172,14 @@ bce_dma_alloc(device_t dev) } if(bus_dmamem_alloc(sc->status_tag, (void **)&sc->status_block, - BUS_DMA_NOWAIT, &sc->status_map)) { + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, + &sc->status_map)) { BCE_PRINTF("%s(%d): Could not allocate status block " "DMA memory!\n", __FILE__, __LINE__); rc = ENOMEM; goto bce_dma_alloc_exit; } - bzero((char *)sc->status_block, BCE_STATUS_BLK_SZ); - error = bus_dmamap_load(sc->status_tag, sc->status_map, sc->status_block, BCE_STATUS_BLK_SZ, bce_dma_map_addr, &sc->status_block_paddr, BUS_DMA_NOWAIT); @@ -3211,15 +3210,13 @@ bce_dma_alloc(device_t dev) } if (bus_dmamem_alloc(sc->stats_tag, (void **)&sc->stats_block, - BUS_DMA_NOWAIT, &sc->stats_map)) { + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->stats_map)) { BCE_PRINTF("%s(%d): Could not allocate statistics block " "DMA memory!\n", __FILE__, __LINE__); rc = ENOMEM; goto bce_dma_alloc_exit; } - bzero((char *)sc->stats_block, BCE_STATS_BLK_SZ); - error = bus_dmamap_load(sc->stats_tag, sc->stats_map, sc->stats_block, BCE_STATS_BLK_SZ, bce_dma_map_addr, &sc->stats_block_paddr, BUS_DMA_NOWAIT); @@ -3265,7 +3262,7 @@ bce_dma_alloc(device_t dev) if(bus_dmamem_alloc(sc->ctx_tag, (void **)&sc->ctx_block[i], - BUS_DMA_NOWAIT, + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->ctx_map[i])) { BCE_PRINTF("%s(%d): Could not allocate CTX " "DMA memory!\n", __FILE__, __LINE__); @@ -3273,8 +3270,6 @@ bce_dma_alloc(device_t dev) goto bce_dma_alloc_exit; } - bzero((char *)sc->ctx_block[i], BCM_PAGE_SIZE); - error = bus_dmamap_load(sc->ctx_tag, sc->ctx_map[i], sc->ctx_block[i], BCM_PAGE_SIZE, bce_dma_map_addr, &sc->ctx_paddr[i], BUS_DMA_NOWAIT); @@ -3310,7 +3305,8 @@ bce_dma_alloc(device_t dev) for (i = 0; i < TX_PAGES; i++) { if(bus_dmamem_alloc(sc->tx_bd_chain_tag, - (void **)&sc->tx_bd_chain[i], BUS_DMA_NOWAIT, + (void **)&sc->tx_bd_chain[i], + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->tx_bd_chain_map[i])) { BCE_PRINTF("%s(%d): Could not allocate TX descriptor " "chain DMA memory!\n", __FILE__, __LINE__); @@ -3386,7 +3382,8 @@ bce_dma_alloc(device_t dev) for (i = 0; i < RX_PAGES; i++) { if (bus_dmamem_alloc(sc->rx_bd_chain_tag, - (void **)&sc->rx_bd_chain[i], BUS_DMA_NOWAIT, + (void **)&sc->rx_bd_chain[i], + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->rx_bd_chain_map[i])) { BCE_PRINTF("%s(%d): Could not allocate RX descriptor " "chain DMA memory!\n", __FILE__, __LINE__); @@ -3394,8 +3391,6 @@ bce_dma_alloc(device_t dev) goto bce_dma_alloc_exit; } - bzero((char *)sc->rx_bd_chain[i], BCE_RX_CHAIN_PAGE_SZ); - error = bus_dmamap_load(sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i], sc->rx_bd_chain[i], BCE_RX_CHAIN_PAGE_SZ, bce_dma_map_addr, @@ -3429,9 +3424,10 @@ bce_dma_alloc(device_t dev) "size = 0x%jX)\n", __FUNCTION__, (uintmax_t) max_size, max_segments, (uintmax_t) max_seg_size); - if (bus_dma_tag_create(sc->parent_tag, 1, BCE_DMA_BOUNDARY, - sc->max_bus_addr, BUS_SPACE_MAXADDR, NULL, NULL, max_size, - max_segments, max_seg_size, 0, NULL, NULL, &sc->rx_mbuf_tag)) { + if (bus_dma_tag_create(sc->parent_tag, 1, + BCE_DMA_BOUNDARY, sc->max_bus_addr, BUS_SPACE_MAXADDR, NULL, NULL, + max_size, max_segments, max_seg_size, 0, NULL, NULL, + &sc->rx_mbuf_tag)) { BCE_PRINTF("%s(%d): Could not allocate RX mbuf DMA tag!\n", __FILE__, __LINE__); rc = ENOMEM; @@ -3468,7 +3464,8 @@ bce_dma_alloc(device_t dev) for (i = 0; i < PG_PAGES; i++) { if (bus_dmamem_alloc(sc->pg_bd_chain_tag, - (void **)&sc->pg_bd_chain[i], BUS_DMA_NOWAIT, + (void **)&sc->pg_bd_chain[i], + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->pg_bd_chain_map[i])) { BCE_PRINTF("%s(%d): Could not allocate page " "descriptor chain DMA memory!\n", @@ -3477,8 +3474,6 @@ bce_dma_alloc(device_t dev) goto bce_dma_alloc_exit; } - bzero((char *)sc->pg_bd_chain[i], BCE_PG_CHAIN_PAGE_SZ); - error = bus_dmamap_load(sc->pg_bd_chain_tag, sc->pg_bd_chain_map[i], sc->pg_bd_chain[i], BCE_PG_CHAIN_PAGE_SZ, bce_dma_map_addr, |