subr_bus_dma.c (251221) | subr_bus_dma.c (257228) |
---|---|
1/*- 2 * Copyright (c) 2012 EMC Corp. 3 * All rights reserved. 4 * 5 * Copyright (c) 1997, 1998 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012 EMC Corp. 3 * All rights reserved. 4 * 5 * Copyright (c) 1997, 1998 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/kern/subr_bus_dma.c 251221 2013-06-01 11:42:47Z marius $"); | 31__FBSDID("$FreeBSD: head/sys/kern/subr_bus_dma.c 257228 2013-10-27 21:39:16Z kib $"); |
32 33#include "opt_bus.h" 34 35#include <sys/param.h> 36#include <sys/conf.h> 37#include <sys/systm.h> 38#include <sys/bio.h> 39#include <sys/bus.h> --- 79 unchanged lines hidden (view full) --- 119 120/* 121 * Load from block io. 122 */ 123static int 124_bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, 125 int *nsegs, int flags) 126{ | 32 33#include "opt_bus.h" 34 35#include <sys/param.h> 36#include <sys/conf.h> 37#include <sys/systm.h> 38#include <sys/bio.h> 39#include <sys/bus.h> --- 79 unchanged lines hidden (view full) --- 119 120/* 121 * Load from block io. 122 */ 123static int 124_bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, 125 int *nsegs, int flags) 126{ |
127 vm_paddr_t paddr; 128 bus_size_t len, tlen; 129 int error, i, ma_offs; | 127 int error; |
130 131 if ((bio->bio_flags & BIO_UNMAPPED) == 0) { 132 error = _bus_dmamap_load_buffer(dmat, map, bio->bio_data, 133 bio->bio_bcount, kernel_pmap, flags, NULL, nsegs); | 128 129 if ((bio->bio_flags & BIO_UNMAPPED) == 0) { 130 error = _bus_dmamap_load_buffer(dmat, map, bio->bio_data, 131 bio->bio_bcount, kernel_pmap, flags, NULL, nsegs); |
134 return (error); | 132 } else { 133 error = _bus_dmamap_load_ma(dmat, map, bio->bio_ma, 134 bio->bio_bcount, bio->bio_ma_offset, flags, NULL, nsegs); |
135 } | 135 } |
136 return (error); 137} |
|
136 | 138 |
139int 140bus_dmamap_load_ma_triv(bus_dma_tag_t dmat, bus_dmamap_t map, 141 struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, 142 bus_dma_segment_t *segs, int *segp) 143{ 144 vm_paddr_t paddr; 145 bus_size_t len; 146 int error, i; 147 |
|
137 error = 0; | 148 error = 0; |
138 tlen = bio->bio_bcount; 139 ma_offs = bio->bio_ma_offset; | |
140 for (i = 0; tlen > 0; i++, tlen -= len) { 141 len = min(PAGE_SIZE - ma_offs, tlen); | 149 for (i = 0; tlen > 0; i++, tlen -= len) { 150 len = min(PAGE_SIZE - ma_offs, tlen); |
142 paddr = VM_PAGE_TO_PHYS(bio->bio_ma[i]) + ma_offs; | 151 paddr = VM_PAGE_TO_PHYS(ma[i]) + ma_offs; |
143 error = _bus_dmamap_load_phys(dmat, map, paddr, len, | 152 error = _bus_dmamap_load_phys(dmat, map, paddr, len, |
144 flags, NULL, nsegs); | 153 flags, segs, segp); |
145 if (error != 0) 146 break; 147 ma_offs = 0; 148 } 149 return (error); 150} 151 152/* --- 381 unchanged lines hidden --- | 154 if (error != 0) 155 break; 156 ma_offs = 0; 157 } 158 return (error); 159} 160 161/* --- 381 unchanged lines hidden --- |