mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Vinod Koul <vinod.koul@intel.com>, Takashi Iwai <tiwai@suse.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	Laurent Pinchart <renesas@ideasonboard.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Qiao Zhou <zhouqiao@marvell.com>,
	Shengjiu Wang <shengjiu.wang@freescale.com>,
	Matt Campbell <mcampbell@izotope.com>,
	Jonah Petri <jpetri@izotope.com>,
	dmaengine@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/4] dmaengine: virt-dma: Add synchronization helper function
Date: Tue, 20 Oct 2015 11:46:29 +0200	[thread overview]
Message-ID: <1445334391-12272-3-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1445334391-12272-1-git-send-email-lars@metafoo.de>

Add a synchronize helper function for the virt-dma library. The function
makes sure that any scheduled descriptor complete callbacks have finished
running before the function returns.

This needs to be called by drivers using virt-dma in their
device_synchronize() callback. Depending on the driver additional
operations might be necessary in addition to calling vchan_synchronize() to
ensure proper synchronization.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/dma/virt-dma.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 181b9526..e93de76 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -151,4 +151,17 @@ static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
 	vchan_dma_desc_free_list(vc, &head);
 }
 
+/**
+ * vchan_synchronize() - synchronize callback execution to the current context
+ * @vc: virtual channel to synchronize
+ *
+ * Makes sure that all scheduled or active callbacks have finished running. For
+ * proper operation the caller has to ensure that no new callbacks are scheduled
+ * after the invocation of this function started.
+ */
+static inline void vchan_synchronize(struct virt_dma_chan *vc)
+{
+	tasklet_kill(&vc->task);
+}
+
 #endif
-- 
2.1.4


  parent reply	other threads:[~2015-10-20  9:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  9:46 [PATCH 0/4] dmaengine: Add transfer termination synchronization support Lars-Peter Clausen
2015-10-20  9:46 ` [PATCH 1/4] " Lars-Peter Clausen
2015-10-29 21:59   ` Andy Shevchenko
2015-10-30 14:16     ` Lars-Peter Clausen
2015-10-20  9:46 ` Lars-Peter Clausen [this message]
2015-10-20  9:46 ` [PATCH 3/4] dmaengine: axi_dmac: Add " Lars-Peter Clausen
2015-10-20  9:46 ` [PATCH 4/4] ALSA: pcm_dmaengine: Properly synchronize DMA on shutdown Lars-Peter Clausen
2015-10-20 11:17   ` Takashi Iwai
2015-10-20 11:40     ` Lars-Peter Clausen
2015-10-20 12:36       ` Takashi Iwai
2015-10-20 13:01       ` Lars-Peter Clausen
2015-10-29  1:26 ` [PATCH 0/4] dmaengine: Add transfer termination synchronization support 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=1445334391-12272-3-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jpetri@izotope.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcampbell@izotope.com \
    --cc=renesas@ideasonboard.com \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=shengjiu.wang@freescale.com \
    --cc=tiwai@suse.com \
    --cc=vinod.koul@intel.com \
    --cc=zhouqiao@marvell.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®