mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
dma: mv_xor: Add support for DMA_INTERRUPT
The driver is capable of supporting DMA_INTERRUPT by issuing a dummy 128-byte transfer. This helps removing a poll in the async_tx stack, replacing it with a completion interrupt. Signed-off-by: Lior Amsalem <alior@marvell.com> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
parent
37380b980e
commit
22843545b2
@ -538,6 +538,24 @@ mv_xor_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
|
||||
return mv_xor_prep_dma_xor(chan, dest, &src, 1, len, flags);
|
||||
}
|
||||
|
||||
static struct dma_async_tx_descriptor *
|
||||
mv_xor_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags)
|
||||
{
|
||||
struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
|
||||
dma_addr_t src, dest;
|
||||
size_t len;
|
||||
|
||||
src = mv_chan->dummy_src_addr;
|
||||
dest = mv_chan->dummy_dst_addr;
|
||||
len = MV_XOR_MIN_BYTE_COUNT;
|
||||
|
||||
/*
|
||||
* We implement the DMA_INTERRUPT operation as a minimum sized
|
||||
* XOR operation with a single dummy source address.
|
||||
*/
|
||||
return mv_xor_prep_dma_xor(chan, dest, &src, 1, len, flags);
|
||||
}
|
||||
|
||||
static void mv_xor_free_chan_resources(struct dma_chan *chan)
|
||||
{
|
||||
struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
|
||||
@ -881,6 +899,10 @@ static int mv_xor_channel_remove(struct mv_xor_chan *mv_chan)
|
||||
|
||||
dma_free_coherent(dev, MV_XOR_POOL_SIZE,
|
||||
mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
|
||||
dma_unmap_single(dev, mv_chan->dummy_src_addr,
|
||||
MV_XOR_MIN_BYTE_COUNT, DMA_FROM_DEVICE);
|
||||
dma_unmap_single(dev, mv_chan->dummy_dst_addr,
|
||||
MV_XOR_MIN_BYTE_COUNT, DMA_TO_DEVICE);
|
||||
|
||||
list_for_each_entry_safe(chan, _chan, &mv_chan->dmadev.channels,
|
||||
device_node) {
|
||||
@ -910,6 +932,16 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
|
||||
|
||||
dma_dev = &mv_chan->dmadev;
|
||||
|
||||
/*
|
||||
* These source and destination dummy buffers are used to implement
|
||||
* a DMA_INTERRUPT operation as a minimum-sized XOR operation.
|
||||
* Hence, we only need to map the buffers at initialization-time.
|
||||
*/
|
||||
mv_chan->dummy_src_addr = dma_map_single(dma_dev->dev,
|
||||
mv_chan->dummy_src, MV_XOR_MIN_BYTE_COUNT, DMA_FROM_DEVICE);
|
||||
mv_chan->dummy_dst_addr = dma_map_single(dma_dev->dev,
|
||||
mv_chan->dummy_dst, MV_XOR_MIN_BYTE_COUNT, DMA_TO_DEVICE);
|
||||
|
||||
/* allocate coherent memory for hardware descriptors
|
||||
* note: writecombine gives slightly better performance, but
|
||||
* requires that we explicitly flush the writes
|
||||
@ -934,6 +966,8 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
|
||||
dma_dev->dev = &pdev->dev;
|
||||
|
||||
/* set prep routines based on capability */
|
||||
if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask))
|
||||
dma_dev->device_prep_dma_interrupt = mv_xor_prep_dma_interrupt;
|
||||
if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask))
|
||||
dma_dev->device_prep_dma_memcpy = mv_xor_prep_dma_memcpy;
|
||||
if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
|
||||
|
@ -28,6 +28,9 @@
|
||||
#define MV_XOR_THRESHOLD 1
|
||||
#define MV_XOR_MAX_CHANNELS 2
|
||||
|
||||
#define MV_XOR_MIN_BYTE_COUNT SZ_128
|
||||
#define MV_XOR_MAX_BYTE_COUNT (SZ_16M - 1)
|
||||
|
||||
/* Values for the XOR_CONFIG register */
|
||||
#define XOR_OPERATION_MODE_XOR 0
|
||||
#define XOR_OPERATION_MODE_MEMCPY 2
|
||||
@ -116,6 +119,9 @@ struct mv_xor_chan {
|
||||
struct list_head all_slots;
|
||||
int slots_allocated;
|
||||
struct tasklet_struct irq_tasklet;
|
||||
char dummy_src[MV_XOR_MIN_BYTE_COUNT];
|
||||
char dummy_dst[MV_XOR_MIN_BYTE_COUNT];
|
||||
dma_addr_t dummy_src_addr, dummy_dst_addr;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -184,9 +190,4 @@ struct mv_xor_desc {
|
||||
#define mv_hw_desc_slot_idx(hw_desc, idx) \
|
||||
((void *)(((unsigned long)hw_desc) + ((idx) << 5)))
|
||||
|
||||
#define MV_XOR_MIN_BYTE_COUNT (128)
|
||||
#define XOR_MAX_BYTE_COUNT ((16 * 1024 * 1024) - 1)
|
||||
#define MV_XOR_MAX_BYTE_COUNT XOR_MAX_BYTE_COUNT
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user