From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/21] dmaengine: edma: Simplify and optimize the edma_execute path
Date: Thu, 10 Sep 2015 11:37:32 +0300 [thread overview]
Message-ID: <1441874270-2399-4-git-send-email-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <1441874270-2399-1-git-send-email-peter.ujfalusi@ti.com>
The code path in edma_execute() and edma_callback() can be simplified
and make it more optimal.
There is not need to call in to edma_execute() when the transfer
has been finished for example.
Also the handling of missed/first or next batch of paRAMs can
be done in a more optimal way.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/dma/edma.c | 76 +++++++++++++++++++++---------------------------------
1 file changed, 29 insertions(+), 47 deletions(-)
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 3e5d4f193005..19fa49d6f555 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -154,15 +154,11 @@ static void edma_execute(struct edma_chan *echan)
struct device *dev = echan->vchan.chan.device->dev;
int i, j, left, nslots;
- /* If either we processed all psets or we're still not started */
- if (!echan->edesc ||
- echan->edesc->pset_nr == echan->edesc->processed) {
- /* Get next vdesc */
+ if (!echan->edesc) {
+ /* Setup is needed for the first transfer */
vdesc = vchan_next_desc(&echan->vchan);
- if (!vdesc) {
- echan->edesc = NULL;
+ if (!vdesc)
return;
- }
list_del(&vdesc->node);
echan->edesc = to_edma_desc(&vdesc->tx);
}
@@ -220,28 +216,26 @@ static void edma_execute(struct edma_chan *echan)
echan->ecc->dummy_slot);
}
- if (edesc->processed <= MAX_NR_SG) {
- dev_dbg(dev, "first transfer starting on channel %d\n",
- echan->ch_num);
- edma_start(echan->ch_num);
- } else {
- dev_dbg(dev, "chan: %d: completed %d elements, resuming\n",
- echan->ch_num, edesc->processed);
- edma_resume(echan->ch_num);
- }
-
- /*
- * This happens due to setup times between intermediate transfers
- * in long SG lists which have to be broken up into transfers of
- * MAX_NR_SG
- */
if (echan->missed) {
+ /*
+ * This happens due to setup times between intermediate
+ * transfers in long SG lists which have to be broken up into
+ * transfers of MAX_NR_SG
+ */
dev_dbg(dev, "missed event on channel %d\n", echan->ch_num);
edma_clean_channel(echan->ch_num);
edma_stop(echan->ch_num);
edma_start(echan->ch_num);
edma_trigger_channel(echan->ch_num);
echan->missed = 0;
+ } else if (edesc->processed <= MAX_NR_SG) {
+ dev_dbg(dev, "first transfer starting on channel %d\n",
+ echan->ch_num);
+ edma_start(echan->ch_num);
+ } else {
+ dev_dbg(dev, "chan: %d: completed %d elements, resuming\n",
+ echan->ch_num, edesc->processed);
+ edma_resume(echan->ch_num);
}
}
@@ -259,20 +253,17 @@ static int edma_terminate_all(struct dma_chan *chan)
* echan->edesc is NULL and exit.)
*/
if (echan->edesc) {
- int cyclic = echan->edesc->cyclic;
-
+ edma_stop(echan->ch_num);
+ /* Move the cyclic channel back to default queue */
+ if (echan->edesc->cyclic)
+ edma_assign_channel_eventq(echan->ch_num,
+ EVENTQ_DEFAULT);
/*
* free the running request descriptor
* since it is not in any of the vdesc lists
*/
edma_desc_free(&echan->edesc->vdesc);
-
echan->edesc = NULL;
- edma_stop(echan->ch_num);
- /* Move the cyclic channel back to default queue */
- if (cyclic)
- edma_assign_channel_eventq(echan->ch_num,
- EVENTQ_DEFAULT);
}
vchan_get_all_descriptors(&echan->vchan, &head);
@@ -725,41 +716,33 @@ static void edma_callback(unsigned ch_num, u16 ch_status, void *data)
edesc = echan->edesc;
- /* Pause the channel for non-cyclic */
- if (!edesc || (edesc && !edesc->cyclic))
- edma_pause(echan->ch_num);
-
+ spin_lock(&echan->vchan.lock);
switch (ch_status) {
case EDMA_DMA_COMPLETE:
- spin_lock(&echan->vchan.lock);
-
if (edesc) {
if (edesc->cyclic) {
vchan_cyclic_callback(&edesc->vdesc);
+ goto out;
} else if (edesc->processed == edesc->pset_nr) {
dev_dbg(dev, "Transfer complete, stopping channel %d\n", ch_num);
edesc->residue = 0;
edma_stop(echan->ch_num);
vchan_cookie_complete(&edesc->vdesc);
- edma_execute(echan);
+ echan->edesc = NULL;
} else {
dev_dbg(dev, "Intermediate transfer complete on channel %d\n", ch_num);
+ edma_pause(echan->ch_num);
+
/* Update statistics for tx_status */
edesc->residue -= edesc->sg_len;
edesc->residue_stat = edesc->residue;
edesc->processed_stat = edesc->processed;
-
- edma_execute(echan);
}
+ edma_execute(echan);
}
-
- spin_unlock(&echan->vchan.lock);
-
break;
case EDMA_DMA_CC_ERROR:
- spin_lock(&echan->vchan.lock);
-
edma_read_slot(EDMA_CHAN_SLOT(echan->slot[0]), &p);
/*
@@ -788,13 +771,12 @@ static void edma_callback(unsigned ch_num, u16 ch_status, void *data)
edma_start(echan->ch_num);
edma_trigger_channel(echan->ch_num);
}
-
- spin_unlock(&echan->vchan.lock);
-
break;
default:
break;
}
+out:
+ spin_unlock(&echan->vchan.lock);
}
/* Alloc channel resources */
--
2.5.1
next prev parent reply other threads:[~2015-09-10 8:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 8:37 [PATCH 00/21] dmaengine/ARM: Merge the edma drivers into one Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 01/21] ARM: common: edma: Fix channel parameter for irq callbacks Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 02/21] ARM: common: edma: Remove unused functions Peter Ujfalusi
2015-09-10 8:37 ` Peter Ujfalusi [this message]
2015-09-10 8:37 ` [PATCH 04/21] ARM: davinci/common: Convert edma driver to handle one eDMA instance per driver Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 05/21] ARM/dmaengine: edma: Move of_dma_controller_register to the dmaengine driver Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 06/21] ARM: common: edma: Internal API to use pointer to 'struct edma' Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 07/21] ARM/dmaengine: edma: Public API to use private struct pointer Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 08/21] ARM/dmaengine: edma: Remove limitation on the number of eDMA controllers Peter Ujfalusi
2015-09-10 8:40 ` Arnd Bergmann
2015-09-10 9:09 ` Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 09/21] ARM: davinci: Add set dma_mask to eDMA devices Peter Ujfalusi
2015-09-10 8:45 ` Arnd Bergmann
2015-09-10 9:13 ` Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 10/21] ARM/dmaengine: edma: Merge the two drivers under drivers/dmaengine Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 11/21] dmaengine: edma: Allocate memory dynamically for bitmaps and structures Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 12/21] dmaengine: edma: Parameter alignment and long line fixes Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 13/21] dmaengine: edma: Use devm_kcalloc when possible Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 14/21] dmaengine: edma: Cleanup regarding the use of dev around the code Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 15/21] dmaengine: edma: Use dev_dbg instead pr_debug Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 16/21] dmaengine: edma: Use the edma_write_slot instead open coded memcpy_toio Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 17/21] dmaengine: edma: Print warning when linking slots from different eDMA Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 18/21] dmaengine: edma: Consolidate the comments for functions Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 19/21] dmaengine: edma: Simplify the interrupt handling Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 20/21] dmaengine: edma: Move the pending error check into helper function Peter Ujfalusi
2015-09-10 8:37 ` [PATCH 21/21] dmaengine: edma: Simplify and optimize ccerr interrupt handler Peter Ujfalusi
2015-09-10 8:47 ` [PATCH 00/21] dmaengine/ARM: Merge the edma drivers into one Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441874270-2399-4-git-send-email-peter.ujfalusi@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox