From: Lars-Peter Clausen <lars@metafoo.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: alsa-devel@alsa-project.org,
Shengjiu Wang <shengjiu.wang@freescale.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Vinod Koul <vinod.koul@intel.com>, Takashi Iwai <tiwai@suse.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Qiao Zhou <zhouqiao@marvell.com>,
Laurent Pinchart <renesas@ideasonboard.com>,
Matt Campbell <mcampbell@izotope.com>,
dmaengine <dmaengine@vger.kernel.org>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Dan Williams <dan.j.williams@intel.com>,
Jonah Petri <jpetri@izotope.com>
Subject: Re: [PATCH 1/4] dmaengine: Add transfer termination synchronization support
Date: Fri, 30 Oct 2015 15:16:13 +0100 [thread overview]
Message-ID: <56337BAD.2060506@metafoo.de> (raw)
In-Reply-To: <CAHp75Vey9zQMCWB63BDsOqEGKQh3SvANWCbH1har-vmXoAquXQ@mail.gmail.com>
On 10/29/2015 10:59 PM, Andy Shevchenko wrote:
> On Tue, Oct 20, 2015 at 12:46 PM, Lars-Peter Clausen <lars@metafoo.de> wrote:
>> The DMAengine API has a long standing race condition that is inherent to
>> the API itself. Calling dmaengine_terminate_all() is supposed to stop and
>> abort any pending or active transfers that have previously been submitted.
>> Unfortunately it is possible that this operation races against a currently
>> running (or with some drivers also scheduled) completion callback.
>
> []
>
>> +/**
>> + * dmaengine_terminate_sync() - Terminate all active DMA transfers
>> + * @chan: The channel for which to terminate the transfers
>> + *
>> + * Calling this function will terminate all active and pending transfers
>> + * that have previously been submitted to the channel. It is similar to
>> + * dmaengine_terminate_async() but guarantees that the DMA transfer has actually
>> + * stopped and that all complete callbacks have finished running when the
>> + * function returns.
>> + *
>> + * This function must only be called from non-atomic context and must not be
>> + * called from within a complete callback of a descriptor submitted on the same
>> + * channel.
>> + */
>> +static inline int dmaengine_terminate_sync(struct dma_chan *chan)
>> +{
>> + int ret;
>
> Might be a good idea to add might_sleep(); here.
Sound like a good idea, thanks, I'll add it (in dmaengine_synchronize() though).
>
>> +
>> + ret = dmaengine_terminate_async(chan);
>> + if (ret)
>> + return ret;
>> +
>> + dmaengine_synchronize(chan);
>> +
>> + return 0;
>> +}
>
>
next prev parent reply other threads:[~2015-10-30 14:16 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 [this message]
2015-10-20 9:46 ` [PATCH 2/4] dmaengine: virt-dma: Add synchronization helper function Lars-Peter Clausen
2015-10-20 9:46 ` [PATCH 3/4] dmaengine: axi_dmac: Add synchronization support 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=56337BAD.2060506@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=andy.shevchenko@gmail.com \
--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