30 #include <linux/slab.h>
33 #include <asm/uaccess.h>
35 static int num_pages_spanned(
struct iovec *iov)
57 int iovec_len_used = 0;
58 int iovec_pages_used = 0;
66 iovec_len_used += iov[nr_iovecs].
iov_len;
67 iovec_pages_used += num_pages_spanned(&iov[nr_iovecs]);
69 }
while (iovec_len_used < len);
72 local_list =
kmalloc(
sizeof(*local_list)
83 for (i = 0; i < nr_iovecs; i++) {
91 page_list->
nr_pages = num_pages_spanned(&iov[i]);
131 for (i = 0; i < pinned_list->
nr_iovecs; i++) {
133 for (j = 0; j < page_list->
nr_pages; j++) {
164 while (iovec_idx < pinned_list->nr_iovecs) {
168 while (!iov[iovec_idx].iov_len)
171 page_list = &pinned_list->
page_list[iovec_idx];
173 iov_byte_offset = ((
unsigned long)iov[iovec_idx].iov_base & ~
PAGE_MASK);
174 page_idx = (((
unsigned long)iov[iovec_idx].iov_base &
PAGE_MASK)
178 while (iov[iovec_idx].iov_len) {
180 copy =
min_t(
int, copy, iov[iovec_idx].iov_len);
183 page_list->
pages[page_idx],
189 dma_async_issue_pending(chan);
194 iov[iovec_idx].
iov_len -= copy;
214 unsigned int offset,
size_t len)
225 if (!chan || !pinned_list) {
233 while (iovec_idx < pinned_list->nr_iovecs) {
237 while (!iov[iovec_idx].iov_len)
240 page_list = &pinned_list->
page_list[iovec_idx];
242 iov_byte_offset = ((
unsigned long)iov[iovec_idx].iov_base & ~
PAGE_MASK);
243 page_idx = (((
unsigned long)iov[iovec_idx].iov_base &
PAGE_MASK)
247 while (iov[iovec_idx].iov_len) {
249 copy =
min_t(
int, copy, iov[iovec_idx].iov_len);
252 page_list->
pages[page_idx],
259 dma_async_issue_pending(chan);
264 iov[iovec_idx].
iov_len -= copy;