* @cd: channel platform data
* @runtime_addr: address for RX/TX according to the runtime config
* @pend_list: queued transactions pending on this channel
+ * @issued_list: issued transactions for this channel
* @done_list: list of completed transactions
* @at: active transaction on this channel
* @lock: a lock for this channel data
const struct pl08x_channel_data *cd;
struct dma_slave_config cfg;
struct list_head pend_list;
+ struct list_head issued_list;
struct list_head done_list;
struct pl08x_txd *at;
spinlock_t lock;
struct pl08x_txd *txd;
u32 val;
- txd = list_first_entry(&plchan->pend_list, struct pl08x_txd, node);
+ txd = list_first_entry(&plchan->issued_list, struct pl08x_txd, node);
list_del(&txd->node);
plchan->at = txd;
}
/* Sum up all queued transactions */
+ if (!list_empty(&plchan->issued_list)) {
+ struct pl08x_txd *txdi;
+ list_for_each_entry(txdi, &plchan->issued_list, node) {
+ struct pl08x_sg *dsg;
+ list_for_each_entry(dsg, &txd->dsg_list, node)
+ bytes += dsg->len;
+ }
+ }
+
if (!list_empty(&plchan->pend_list)) {
struct pl08x_txd *txdi;
list_for_each_entry(txdi, &plchan->pend_list, node) {
static void pl08x_free_txd_list(struct pl08x_driver_data *pl08x,
struct pl08x_dma_chan *plchan)
{
- struct pl08x_txd *txdi = NULL;
- struct pl08x_txd *next;
+ LIST_HEAD(head);
+ struct pl08x_txd *txd;
- if (!list_empty(&plchan->pend_list)) {
- list_for_each_entry_safe(txdi,
- next, &plchan->pend_list, node) {
- pl08x_release_mux(plchan);
- list_del(&txdi->node);
- pl08x_free_txd(pl08x, txdi);
- }
+ list_splice_tail_init(&plchan->issued_list, &head);
+ list_splice_tail_init(&plchan->pend_list, &head);
+
+ while (!list_empty(&head)) {
+ txd = list_first_entry(&head, struct pl08x_txd, node);
+ pl08x_release_mux(plchan);
+ list_del(&txd->node);
+ pl08x_free_txd(pl08x, txd);
}
}
unsigned long flags;
spin_lock_irqsave(&plchan->lock, flags);
+ list_splice_tail_init(&plchan->pend_list, &plchan->issued_list);
+
/* Something is already active, or we're waiting for a channel... */
if (plchan->at || plchan->state == PL08X_CHAN_WAITING) {
spin_unlock_irqrestore(&plchan->lock, flags);
}
/* Take the first element in the queue and execute it */
- if (!list_empty(&plchan->pend_list)) {
+ if (!list_empty(&plchan->issued_list)) {
plchan->state = PL08X_CHAN_RUNNING;
pl08x_start_next_txd(plchan);
}
list_splice_tail_init(&plchan->done_list, &head);
/* If a new descriptor is queued, set it up plchan->at is NULL here */
- if (!list_empty(&plchan->pend_list)) {
+ if (!list_empty(&plchan->issued_list)) {
pl08x_start_next_txd(plchan);
- } else if (plchan->phychan_hold) {
+ } else if (!list_empty(&plchan->pend_list) || plchan->phychan_hold) {
/*
* This channel is still in use - we have a new txd being
* prepared and will soon be queued. Don't give up the
spin_lock_init(&chan->lock);
INIT_LIST_HEAD(&chan->pend_list);
+ INIT_LIST_HEAD(&chan->issued_list);
INIT_LIST_HEAD(&chan->done_list);
tasklet_init(&chan->tasklet, pl08x_tasklet,
(unsigned long) chan);