Commit dfc97661 authored by Lior Amsalem's avatar Lior Amsalem Committed by Vinod Koul

dma: mv_xor: Remove multi-slot support

Although the driver supported multiple-slot allocation, only one slot was
ever allocated for each transaction. So, given we have no users of the
multi-slot support, we can remove it and greatly simplify the code.
Signed-off-by: default avatarLior Amsalem <alior@marvell.com>
Signed-off-by: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 3e4f52e2
...@@ -45,19 +45,15 @@ static void mv_xor_issue_pending(struct dma_chan *chan); ...@@ -45,19 +45,15 @@ static void mv_xor_issue_pending(struct dma_chan *chan);
#define mv_chan_to_devp(chan) \ #define mv_chan_to_devp(chan) \
((chan)->dmadev.dev) ((chan)->dmadev.dev)
static void mv_desc_init(struct mv_xor_desc_slot *desc, unsigned long flags) static void mv_desc_init(struct mv_xor_desc_slot *desc,
dma_addr_t addr, u32 byte_count)
{ {
struct mv_xor_desc *hw_desc = desc->hw_desc; struct mv_xor_desc *hw_desc = desc->hw_desc;
hw_desc->status = (1 << 31); hw_desc->status = (1 << 31);
hw_desc->phy_next_desc = 0; hw_desc->phy_next_desc = 0;
hw_desc->desc_command = (1 << 31); hw_desc->desc_command = (1 << 31);
} hw_desc->phy_dest_addr = addr;
static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc,
u32 byte_count)
{
struct mv_xor_desc *hw_desc = desc->hw_desc;
hw_desc->byte_count = byte_count; hw_desc->byte_count = byte_count;
} }
...@@ -75,13 +71,6 @@ static void mv_desc_clear_next_desc(struct mv_xor_desc_slot *desc) ...@@ -75,13 +71,6 @@ static void mv_desc_clear_next_desc(struct mv_xor_desc_slot *desc)
hw_desc->phy_next_desc = 0; hw_desc->phy_next_desc = 0;
} }
static void mv_desc_set_dest_addr(struct mv_xor_desc_slot *desc,
dma_addr_t addr)
{
struct mv_xor_desc *hw_desc = desc->hw_desc;
hw_desc->phy_dest_addr = addr;
}
static void mv_desc_set_src_addr(struct mv_xor_desc_slot *desc, static void mv_desc_set_src_addr(struct mv_xor_desc_slot *desc,
int index, dma_addr_t addr) int index, dma_addr_t addr)
{ {
...@@ -188,11 +177,6 @@ static char mv_chan_is_busy(struct mv_xor_chan *chan) ...@@ -188,11 +177,6 @@ static char mv_chan_is_busy(struct mv_xor_chan *chan)
return (state == 1) ? 1 : 0; return (state == 1) ? 1 : 0;
} }
static int mv_chan_xor_slot_count(size_t len, int src_cnt)
{
return 1;
}
/** /**
* mv_xor_free_slots - flags descriptor slots for reuse * mv_xor_free_slots - flags descriptor slots for reuse
* @slot: Slot to free * @slot: Slot to free
...@@ -204,7 +188,7 @@ static void mv_xor_free_slots(struct mv_xor_chan *mv_chan, ...@@ -204,7 +188,7 @@ static void mv_xor_free_slots(struct mv_xor_chan *mv_chan,
dev_dbg(mv_chan_to_devp(mv_chan), "%s %d slot %p\n", dev_dbg(mv_chan_to_devp(mv_chan), "%s %d slot %p\n",
__func__, __LINE__, slot); __func__, __LINE__, slot);
slot->slots_per_op = 0; slot->slot_used = 0;
} }
...@@ -222,7 +206,7 @@ static void mv_xor_start_new_chain(struct mv_xor_chan *mv_chan, ...@@ -222,7 +206,7 @@ static void mv_xor_start_new_chain(struct mv_xor_chan *mv_chan,
/* set the hardware chain */ /* set the hardware chain */
mv_chan_set_next_descriptor(mv_chan, sw_desc->async_tx.phys); mv_chan_set_next_descriptor(mv_chan, sw_desc->async_tx.phys);
mv_chan->pending += sw_desc->slot_cnt; mv_chan->pending++;
mv_xor_issue_pending(&mv_chan->dmachan); mv_xor_issue_pending(&mv_chan->dmachan);
} }
...@@ -243,8 +227,6 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, ...@@ -243,8 +227,6 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc,
desc->async_tx.callback_param); desc->async_tx.callback_param);
dma_descriptor_unmap(&desc->async_tx); dma_descriptor_unmap(&desc->async_tx);
if (desc->group_head)
desc->group_head = NULL;
} }
/* run dependent operations */ /* run dependent operations */
...@@ -361,19 +343,16 @@ static void mv_xor_tasklet(unsigned long data) ...@@ -361,19 +343,16 @@ static void mv_xor_tasklet(unsigned long data)
} }
static struct mv_xor_desc_slot * static struct mv_xor_desc_slot *
mv_xor_alloc_slots(struct mv_xor_chan *mv_chan, int num_slots, mv_xor_alloc_slot(struct mv_xor_chan *mv_chan)
int slots_per_op)
{ {
struct mv_xor_desc_slot *iter, *_iter, *alloc_start = NULL; struct mv_xor_desc_slot *iter, *_iter;
LIST_HEAD(chain); int retry = 0;
int slots_found, retry = 0;
/* start search from the last allocated descrtiptor /* start search from the last allocated descrtiptor
* if a contiguous allocation can not be found start searching * if a contiguous allocation can not be found start searching
* from the beginning of the list * from the beginning of the list
*/ */
retry: retry:
slots_found = 0;
if (retry == 0) if (retry == 0)
iter = mv_chan->last_used; iter = mv_chan->last_used;
else else
...@@ -383,55 +362,29 @@ mv_xor_alloc_slots(struct mv_xor_chan *mv_chan, int num_slots, ...@@ -383,55 +362,29 @@ mv_xor_alloc_slots(struct mv_xor_chan *mv_chan, int num_slots,
list_for_each_entry_safe_continue( list_for_each_entry_safe_continue(
iter, _iter, &mv_chan->all_slots, slot_node) { iter, _iter, &mv_chan->all_slots, slot_node) {
prefetch(_iter); prefetch(_iter);
prefetch(&_iter->async_tx); prefetch(&_iter->async_tx);
if (iter->slots_per_op) { if (iter->slot_used) {
/* give up after finding the first busy slot /* give up after finding the first busy slot
* on the second pass through the list * on the second pass through the list
*/ */
if (retry) if (retry)
break; break;
slots_found = 0;
continue; continue;
} }
/* start the allocation if the slot is correctly aligned */ /* pre-ack descriptor */
if (!slots_found++) async_tx_ack(&iter->async_tx);
alloc_start = iter;
if (slots_found == num_slots) { iter->slot_used = 1;
struct mv_xor_desc_slot *alloc_tail = NULL; INIT_LIST_HEAD(&iter->chain_node);
struct mv_xor_desc_slot *last_used = NULL; iter->async_tx.cookie = -EBUSY;
iter = alloc_start; mv_chan->last_used = iter;
while (num_slots) { mv_desc_clear_next_desc(iter);
int i;
/* pre-ack all but the last descriptor */ return iter;
async_tx_ack(&iter->async_tx);
list_add_tail(&iter->chain_node, &chain);
alloc_tail = iter;
iter->async_tx.cookie = 0;
iter->slot_cnt = num_slots;
iter->xor_check_result = NULL;
for (i = 0; i < slots_per_op; i++) {
iter->slots_per_op = slots_per_op - i;
last_used = iter;
iter = list_entry(iter->slot_node.next,
struct mv_xor_desc_slot,
slot_node);
}
num_slots -= slots_per_op;
}
alloc_tail->group_head = alloc_start;
alloc_tail->async_tx.cookie = -EBUSY;
list_splice(&chain, &alloc_tail->tx_list);
mv_chan->last_used = last_used;
mv_desc_clear_next_desc(alloc_start);
mv_desc_clear_next_desc(alloc_tail);
return alloc_tail;
}
} }
if (!retry++) if (!retry++)
goto retry; goto retry;
...@@ -448,7 +401,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx) ...@@ -448,7 +401,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
{ {
struct mv_xor_desc_slot *sw_desc = to_mv_xor_slot(tx); struct mv_xor_desc_slot *sw_desc = to_mv_xor_slot(tx);
struct mv_xor_chan *mv_chan = to_mv_xor_chan(tx->chan); struct mv_xor_chan *mv_chan = to_mv_xor_chan(tx->chan);
struct mv_xor_desc_slot *grp_start, *old_chain_tail; struct mv_xor_desc_slot *old_chain_tail;
dma_cookie_t cookie; dma_cookie_t cookie;
int new_hw_chain = 1; int new_hw_chain = 1;
...@@ -456,27 +409,24 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx) ...@@ -456,27 +409,24 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
"%s sw_desc %p: async_tx %p\n", "%s sw_desc %p: async_tx %p\n",
__func__, sw_desc, &sw_desc->async_tx); __func__, sw_desc, &sw_desc->async_tx);
grp_start = sw_desc->group_head;
spin_lock_bh(&mv_chan->lock); spin_lock_bh(&mv_chan->lock);
cookie = dma_cookie_assign(tx); cookie = dma_cookie_assign(tx);
if (list_empty(&mv_chan->chain)) if (list_empty(&mv_chan->chain))
list_splice_init(&sw_desc->tx_list, &mv_chan->chain); list_add_tail(&sw_desc->chain_node, &mv_chan->chain);
else { else {
new_hw_chain = 0; new_hw_chain = 0;
old_chain_tail = list_entry(mv_chan->chain.prev, old_chain_tail = list_entry(mv_chan->chain.prev,
struct mv_xor_desc_slot, struct mv_xor_desc_slot,
chain_node); chain_node);
list_splice_init(&grp_start->tx_list, list_add_tail(&sw_desc->chain_node, &mv_chan->chain);
&old_chain_tail->chain_node);
dev_dbg(mv_chan_to_devp(mv_chan), "Append to last desc %pa\n", dev_dbg(mv_chan_to_devp(mv_chan), "Append to last desc %pa\n",
&old_chain_tail->async_tx.phys); &old_chain_tail->async_tx.phys);
/* fix up the hardware chain */ /* fix up the hardware chain */
mv_desc_set_next_desc(old_chain_tail, grp_start->async_tx.phys); mv_desc_set_next_desc(old_chain_tail, sw_desc->async_tx.phys);
/* if the channel is not busy */ /* if the channel is not busy */
if (!mv_chan_is_busy(mv_chan)) { if (!mv_chan_is_busy(mv_chan)) {
...@@ -491,7 +441,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx) ...@@ -491,7 +441,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
} }
if (new_hw_chain) if (new_hw_chain)
mv_xor_start_new_chain(mv_chan, grp_start); mv_xor_start_new_chain(mv_chan, sw_desc);
spin_unlock_bh(&mv_chan->lock); spin_unlock_bh(&mv_chan->lock);
...@@ -525,7 +475,6 @@ static int mv_xor_alloc_chan_resources(struct dma_chan *chan) ...@@ -525,7 +475,6 @@ static int mv_xor_alloc_chan_resources(struct dma_chan *chan)
slot->async_tx.tx_submit = mv_xor_tx_submit; slot->async_tx.tx_submit = mv_xor_tx_submit;
INIT_LIST_HEAD(&slot->chain_node); INIT_LIST_HEAD(&slot->chain_node);
INIT_LIST_HEAD(&slot->slot_node); INIT_LIST_HEAD(&slot->slot_node);
INIT_LIST_HEAD(&slot->tx_list);
dma_desc = mv_chan->dma_desc_pool; dma_desc = mv_chan->dma_desc_pool;
slot->async_tx.phys = dma_desc + idx * MV_XOR_SLOT_SIZE; slot->async_tx.phys = dma_desc + idx * MV_XOR_SLOT_SIZE;
slot->idx = idx++; slot->idx = idx++;
...@@ -553,8 +502,7 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, ...@@ -553,8 +502,7 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
unsigned int src_cnt, size_t len, unsigned long flags) unsigned int src_cnt, size_t len, unsigned long flags)
{ {
struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
struct mv_xor_desc_slot *sw_desc, *grp_start; struct mv_xor_desc_slot *sw_desc;
int slot_cnt;
if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) if (unlikely(len < MV_XOR_MIN_BYTE_COUNT))
return NULL; return NULL;
...@@ -566,19 +514,15 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, ...@@ -566,19 +514,15 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
__func__, src_cnt, len, &dest, flags); __func__, src_cnt, len, &dest, flags);
spin_lock_bh(&mv_chan->lock); spin_lock_bh(&mv_chan->lock);
slot_cnt = mv_chan_xor_slot_count(len, src_cnt); sw_desc = mv_xor_alloc_slot(mv_chan);
sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1);
if (sw_desc) { if (sw_desc) {
sw_desc->type = DMA_XOR; sw_desc->type = DMA_XOR;
sw_desc->async_tx.flags = flags; sw_desc->async_tx.flags = flags;
grp_start = sw_desc->group_head; mv_desc_init(sw_desc, dest, len);
mv_desc_init(grp_start, flags);
mv_desc_set_byte_count(grp_start, len);
mv_desc_set_dest_addr(sw_desc->group_head, dest);
sw_desc->unmap_src_cnt = src_cnt; sw_desc->unmap_src_cnt = src_cnt;
sw_desc->unmap_len = len; sw_desc->unmap_len = len;
while (src_cnt--) while (src_cnt--)
mv_desc_set_src_addr(grp_start, src_cnt, src[src_cnt]); mv_desc_set_src_addr(sw_desc, src_cnt, src[src_cnt]);
} }
spin_unlock_bh(&mv_chan->lock); spin_unlock_bh(&mv_chan->lock);
dev_dbg(mv_chan_to_devp(mv_chan), dev_dbg(mv_chan_to_devp(mv_chan),
......
...@@ -110,9 +110,7 @@ struct mv_xor_chan { ...@@ -110,9 +110,7 @@ struct mv_xor_chan {
* @completed_node: node on the mv_xor_chan.completed_slots list * @completed_node: node on the mv_xor_chan.completed_slots list
* @hw_desc: virtual address of the hardware descriptor chain * @hw_desc: virtual address of the hardware descriptor chain
* @phys: hardware address of the hardware descriptor chain * @phys: hardware address of the hardware descriptor chain
* @group_head: first operation in a transaction * @slot_used: slot in use or not
* @slot_cnt: total slots used in an transaction (group of operations)
* @slots_per_op: number of slots per operation
* @idx: pool index * @idx: pool index
* @unmap_src_cnt: number of xor sources * @unmap_src_cnt: number of xor sources
* @unmap_len: transaction bytecount * @unmap_len: transaction bytecount
...@@ -127,14 +125,11 @@ struct mv_xor_desc_slot { ...@@ -127,14 +125,11 @@ struct mv_xor_desc_slot {
struct list_head completed_node; struct list_head completed_node;
enum dma_transaction_type type; enum dma_transaction_type type;
void *hw_desc; void *hw_desc;
struct mv_xor_desc_slot *group_head; u16 slot_used;
u16 slot_cnt;
u16 slots_per_op;
u16 idx; u16 idx;
u16 unmap_src_cnt; u16 unmap_src_cnt;
u32 value; u32 value;
size_t unmap_len; size_t unmap_len;
struct list_head tx_list;
struct dma_async_tx_descriptor async_tx; struct dma_async_tx_descriptor async_tx;
union { union {
u32 *xor_check_result; u32 *xor_check_result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment