Skip to content

Commit

Permalink
dma: axi-dmac: terminate early DMA transfers after a partial one
Browse files Browse the repository at this point in the history
When we get a partial transfer, we should not submit any more segments to
the hardware, as the data it will get will be unused and will just do
unnecessary processing.

During the start of transfer, we check it there was a partial transfer in a
previous completed segment and add the TLAST flag to the next segment that
is about to be submitted.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
  • Loading branch information
commodo committed Nov 20, 2018
1 parent 31baa60 commit 70b6b10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/dma/dma-axi-dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct axi_dmac_sg {
struct axi_dmac_desc {
struct virt_dma_desc vdesc;
bool cyclic;
bool have_partial_xfer;

unsigned int num_submitted;
unsigned int num_completed;
Expand Down Expand Up @@ -234,7 +235,8 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)
}

desc->num_submitted++;
if (desc->num_submitted == desc->num_sgs) {
if (desc->num_submitted == desc->num_sgs ||
desc->have_partial_xfer) {
if (desc->cyclic) {
desc->num_submitted = 0; /* Start again */
} else {
Expand Down Expand Up @@ -309,6 +311,7 @@ static void axi_dmac_dequeue_partial_xfers(struct axi_dmac_chan *chan)
if (sg->id == AXI_DMAC_SG_UNUSED)
continue;
if (sg->id == id) {
desc->have_partial_xfer = true;
sg->partial_len = len;
found_sg = true;
break;
Expand Down

0 comments on commit 70b6b10

Please sign in to comment.