mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: <vinod.koul@intel.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lars@metafoo.de>
Subject: [PATCH 01/10] dmaengine: virt-dma: Add helper to free/reuse a descriptor
Date: Tue, 14 Nov 2017 16:32:03 +0200	[thread overview]
Message-ID: <20171114143212.8311-2-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <20171114143212.8311-1-peter.ujfalusi@ti.com>

The vchan_vdesc_fini() can be used to free or reuse a given descriptor
after it has been marked as completed.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/virt-dma.c |  5 +----
 drivers/dma/virt-dma.h | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/virt-dma.c b/drivers/dma/virt-dma.c
index 545e97279083..88ad8ed2a8d6 100644
--- a/drivers/dma/virt-dma.c
+++ b/drivers/dma/virt-dma.c
@@ -107,10 +107,7 @@ static void vchan_complete(unsigned long arg)
 		dmaengine_desc_get_callback(&vd->tx, &cb);
 
 		list_del(&vd->node);
-		if (dmaengine_desc_test_reuse(&vd->tx))
-			list_add(&vd->node, &vc->desc_allocated);
-		else
-			vc->desc_free(vd);
+		vchan_vdesc_fini(vd);
 
 		dmaengine_desc_callback_invoke(&cb, NULL);
 	}
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 3f776a46a29c..2edb05505102 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -103,6 +103,20 @@ static inline void vchan_cookie_complete(struct virt_dma_desc *vd)
 	tasklet_schedule(&vc->task);
 }
 
+/**
+ * vchan_vdesc_fini - Free or reuse a descriptor
+ * @vd: virtual descriptor to free/reuse
+ */
+static inline void vchan_vdesc_fini(struct virt_dma_desc *vd)
+{
+	struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
+
+	if (dmaengine_desc_test_reuse(&vd->tx))
+		list_add(&vd->node, &vc->desc_allocated);
+	else
+		vc->desc_free(vd);
+}
+
 /**
  * vchan_cyclic_callback - report the completion of a period
  * @vd: virtual descriptor
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2017-11-14 14:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 14:32 [PATCH 00/10] dmaengine: fix race with vchan_complete Peter Ujfalusi
2017-11-14 14:32 ` Peter Ujfalusi [this message]
2017-11-15  7:49   ` [PATCH 01/10] dmaengine: virt-dma: Add helper to free/reuse a descriptor Linus Walleij
2017-11-14 14:32 ` [PATCH 02/10] dmaengine: virt-dma: Support for race free transfer termination Peter Ujfalusi
2017-11-15  7:50   ` Linus Walleij
2017-11-14 14:32 ` [PATCH 03/10] dmaengine: omap-dma: Use vchan_terminate_vdesc() instead of desc_free Peter Ujfalusi
2017-11-14 14:32 ` [PATCH 04/10] dmaengine: edma: " Peter Ujfalusi
2017-11-14 14:32 ` [PATCH 05/10] dmaengine: bcm2835-dma: " Peter Ujfalusi
2017-11-15 18:53   ` Eric Anholt
2017-11-21 11:42     ` Peter Ujfalusi
2017-11-14 14:32 ` [PATCH 06/10] dmaengine: dma-jz4780: " Peter Ujfalusi
2017-11-14 14:32 ` [PATCH 07/10] dmaengine: amba-pl08x: " Peter Ujfalusi
2017-11-15  7:48   ` Linus Walleij
2017-11-14 14:32 ` [PATCH 08/10] dmaengine: img-mdc-dma: " Peter Ujfalusi
2017-11-14 14:32 ` [PATCH 09/10] dmaengine: k3dma: " Peter Ujfalusi
2017-11-15  4:06   ` zhangfei
2017-11-14 14:32 ` [PATCH 10/10] dmaengine: s3c24xx-dma: " Peter Ujfalusi
2017-11-14 14:47 ` [PATCH 00/10] dmaengine: fix race with vchan_complete Peter Ujfalusi
2017-12-04 17:07 ` Vinod Koul

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=20171114143212.8311-2-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vinod.koul@intel.com \
    /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

all inboxes | Powered by JetHome®