Blame view
crypto/async_tx/async_memcpy.c
2.98 KB
9bc89cd82 async_tx: add the... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
/* * copy offload engine support * * Copyright © 2006, Intel Corporation. * * Dan Williams <dan.j.williams@intel.com> * * with architecture considerations by: * Neil Brown <neilb@suse.de> * Jeff Garzik <jeff@garzik.org> * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. * */ #include <linux/kernel.h> #include <linux/highmem.h> |
4bb33cc89 crypto: add modul... |
28 |
#include <linux/module.h> |
9bc89cd82 async_tx: add the... |
29 30 31 32 33 34 35 36 |
#include <linux/mm.h> #include <linux/dma-mapping.h> #include <linux/async_tx.h> /** * async_memcpy - attempt to copy memory with a dma engine. * @dest: destination page * @src: src page |
a08abd8ca async_tx: structi... |
37 38 |
* @dest_offset: offset into 'dest' to start transaction * @src_offset: offset into 'src' to start transaction |
9bc89cd82 async_tx: add the... |
39 |
* @len: length in bytes |
a08abd8ca async_tx: structi... |
40 41 42 |
* @submit: submission / completion modifiers * * honored flags: ASYNC_TX_ACK |
9bc89cd82 async_tx: add the... |
43 44 45 |
*/ struct dma_async_tx_descriptor * async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, |
a08abd8ca async_tx: structi... |
46 47 |
unsigned int src_offset, size_t len, struct async_submit_ctl *submit) |
9bc89cd82 async_tx: add the... |
48 |
{ |
a08abd8ca async_tx: structi... |
49 |
struct dma_chan *chan = async_tx_find_channel(submit, DMA_MEMCPY, |
47437b2c9 async_tx: allow a... |
50 |
&dest, 1, &src, 1, len); |
9bc89cd82 async_tx: add the... |
51 |
struct dma_device *device = chan ? chan->device : NULL; |
0036731c8 async_tx: kill tx... |
52 |
struct dma_async_tx_descriptor *tx = NULL; |
9bc89cd82 async_tx: add the... |
53 |
|
83544ae9f dmaengine, async_... |
54 |
if (device && is_dma_copy_aligned(device, src_offset, dest_offset, len)) { |
0036731c8 async_tx: kill tx... |
55 |
dma_addr_t dma_dest, dma_src; |
0403e3827 dmaengine: add fe... |
56 |
unsigned long dma_prep_flags = 0; |
9bc89cd82 async_tx: add the... |
57 |
|
0403e3827 dmaengine: add fe... |
58 59 60 61 |
if (submit->cb_fn) dma_prep_flags |= DMA_PREP_INTERRUPT; if (submit->flags & ASYNC_TX_FENCE) dma_prep_flags |= DMA_PREP_FENCE; |
0036731c8 async_tx: kill tx... |
62 63 |
dma_dest = dma_map_page(device->dev, dest, dest_offset, len, DMA_FROM_DEVICE); |
9bc89cd82 async_tx: add the... |
64 |
|
0036731c8 async_tx: kill tx... |
65 66 |
dma_src = dma_map_page(device->dev, src, src_offset, len, DMA_TO_DEVICE); |
9bc89cd82 async_tx: add the... |
67 |
|
0036731c8 async_tx: kill tx... |
68 |
tx = device->device_prep_dma_memcpy(chan, dma_dest, dma_src, |
d4c56f97f async_tx: replace... |
69 |
len, dma_prep_flags); |
0036731c8 async_tx: kill tx... |
70 |
} |
9bc89cd82 async_tx: add the... |
71 |
|
0036731c8 async_tx: kill tx... |
72 |
if (tx) { |
3280ab3e8 async_tx: checkpa... |
73 74 |
pr_debug("%s: (async) len: %zu ", __func__, len); |
a08abd8ca async_tx: structi... |
75 |
async_tx_submit(chan, tx, submit); |
0036731c8 async_tx: kill tx... |
76 |
} else { |
9bc89cd82 async_tx: add the... |
77 |
void *dest_buf, *src_buf; |
3280ab3e8 async_tx: checkpa... |
78 79 |
pr_debug("%s: (sync) len: %zu ", __func__, len); |
9bc89cd82 async_tx: add the... |
80 81 |
/* wait for any prerequisite operations */ |
a08abd8ca async_tx: structi... |
82 |
async_tx_quiesce(&submit->depend_tx); |
9bc89cd82 async_tx: add the... |
83 |
|
eb0645a8b async_tx: fix kma... |
84 85 |
dest_buf = kmap_atomic(dest, KM_USER0) + dest_offset; src_buf = kmap_atomic(src, KM_USER1) + src_offset; |
9bc89cd82 async_tx: add the... |
86 87 |
memcpy(dest_buf, src_buf, len); |
eb0645a8b async_tx: fix kma... |
88 |
kunmap_atomic(src_buf, KM_USER1); |
61ecdb801 mm: strictly nest... |
89 |
kunmap_atomic(dest_buf, KM_USER0); |
9bc89cd82 async_tx: add the... |
90 |
|
a08abd8ca async_tx: structi... |
91 |
async_tx_sync_epilog(submit); |
9bc89cd82 async_tx: add the... |
92 93 94 95 96 |
} return tx; } EXPORT_SYMBOL_GPL(async_memcpy); |
9bc89cd82 async_tx: add the... |
97 98 99 |
MODULE_AUTHOR("Intel Corporation"); MODULE_DESCRIPTION("asynchronous memcpy api"); MODULE_LICENSE("GPL"); |