async_memcpy: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers. Cc: Vinod Koul <vinod.koul@intel.com> Cc: Tomasz Figa <t.figa@samsung.com> Cc: Dave Jiang <dave.jiang@intel.com> Reported-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> [bzolnier: add missing unmap->len initialization] [bzolnier: fix whitespace damage] Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> [djbw: add DMA_ENGINE=n support] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
45c463ae92
commit
8971646294
3 changed files with 40 additions and 16 deletions
|
@ -50,33 +50,37 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
|
||||||
&dest, 1, &src, 1, len);
|
&dest, 1, &src, 1, len);
|
||||||
struct dma_device *device = chan ? chan->device : NULL;
|
struct dma_device *device = chan ? chan->device : NULL;
|
||||||
struct dma_async_tx_descriptor *tx = NULL;
|
struct dma_async_tx_descriptor *tx = NULL;
|
||||||
|
struct dmaengine_unmap_data *unmap = NULL;
|
||||||
|
|
||||||
if (device && is_dma_copy_aligned(device, src_offset, dest_offset, len)) {
|
if (device)
|
||||||
dma_addr_t dma_dest, dma_src;
|
unmap = dmaengine_get_unmap_data(device->dev, 2, GFP_NOIO);
|
||||||
unsigned long dma_prep_flags = 0;
|
|
||||||
|
if (unmap && is_dma_copy_aligned(device, src_offset, dest_offset, len)) {
|
||||||
|
unsigned long dma_prep_flags = DMA_COMPL_SKIP_SRC_UNMAP |
|
||||||
|
DMA_COMPL_SKIP_DEST_UNMAP;
|
||||||
|
|
||||||
if (submit->cb_fn)
|
if (submit->cb_fn)
|
||||||
dma_prep_flags |= DMA_PREP_INTERRUPT;
|
dma_prep_flags |= DMA_PREP_INTERRUPT;
|
||||||
if (submit->flags & ASYNC_TX_FENCE)
|
if (submit->flags & ASYNC_TX_FENCE)
|
||||||
dma_prep_flags |= DMA_PREP_FENCE;
|
dma_prep_flags |= DMA_PREP_FENCE;
|
||||||
dma_dest = dma_map_page(device->dev, dest, dest_offset, len,
|
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
|
|
||||||
dma_src = dma_map_page(device->dev, src, src_offset, len,
|
unmap->to_cnt = 1;
|
||||||
DMA_TO_DEVICE);
|
unmap->addr[0] = dma_map_page(device->dev, src, src_offset, len,
|
||||||
|
DMA_TO_DEVICE);
|
||||||
|
unmap->from_cnt = 1;
|
||||||
|
unmap->addr[1] = dma_map_page(device->dev, dest, dest_offset, len,
|
||||||
|
DMA_FROM_DEVICE);
|
||||||
|
unmap->len = len;
|
||||||
|
|
||||||
tx = device->device_prep_dma_memcpy(chan, dma_dest, dma_src,
|
tx = device->device_prep_dma_memcpy(chan, unmap->addr[1],
|
||||||
len, dma_prep_flags);
|
unmap->addr[0], len,
|
||||||
if (!tx) {
|
dma_prep_flags);
|
||||||
dma_unmap_page(device->dev, dma_dest, len,
|
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
dma_unmap_page(device->dev, dma_src, len,
|
|
||||||
DMA_TO_DEVICE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) {
|
if (tx) {
|
||||||
pr_debug("%s: (async) len: %zu\n", __func__, len);
|
pr_debug("%s: (async) len: %zu\n", __func__, len);
|
||||||
|
|
||||||
|
dma_set_unmap(tx, unmap);
|
||||||
async_tx_submit(chan, tx, submit);
|
async_tx_submit(chan, tx, submit);
|
||||||
} else {
|
} else {
|
||||||
void *dest_buf, *src_buf;
|
void *dest_buf, *src_buf;
|
||||||
|
@ -96,6 +100,8 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
|
||||||
async_tx_sync_epilog(submit);
|
async_tx_sync_epilog(submit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dmaengine_unmap_put(unmap);
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(async_memcpy);
|
EXPORT_SYMBOL_GPL(async_memcpy);
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ static int __init dmaengine_init_unmap_pool(void)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dmaengine_unmap_data *
|
struct dmaengine_unmap_data *
|
||||||
dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
|
dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
|
||||||
{
|
{
|
||||||
struct dmaengine_unmap_data *unmap;
|
struct dmaengine_unmap_data *unmap;
|
||||||
|
@ -1024,6 +1024,7 @@ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
|
||||||
|
|
||||||
return unmap;
|
return unmap;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(dmaengine_get_unmap_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dma_async_memcpy_pg_to_pg - offloaded copy from page to page
|
* dma_async_memcpy_pg_to_pg - offloaded copy from page to page
|
||||||
|
|
|
@ -457,6 +457,7 @@ struct dma_async_tx_descriptor {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_DMA_ENGINE
|
||||||
static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
|
static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
|
||||||
struct dmaengine_unmap_data *unmap)
|
struct dmaengine_unmap_data *unmap)
|
||||||
{
|
{
|
||||||
|
@ -464,7 +465,23 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
|
||||||
tx->unmap = unmap;
|
tx->unmap = unmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct dmaengine_unmap_data *
|
||||||
|
dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags);
|
||||||
void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap);
|
void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap);
|
||||||
|
#else
|
||||||
|
static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
|
||||||
|
struct dmaengine_unmap_data *unmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
static inline struct dmaengine_unmap_data *
|
||||||
|
dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
static inline void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void dma_descriptor_unmap(struct dma_async_tx_descriptor *tx)
|
static inline void dma_descriptor_unmap(struct dma_async_tx_descriptor *tx)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue