[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vey9zQMCWB63BDsOqEGKQh3SvANWCbH1har-vmXoAquXQ@mail.gmail.com>
Date: Thu, 29 Oct 2015 23:59:40 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Lars-Peter Clausen <lars@...afoo.de>
Cc: Vinod Koul <vinod.koul@...el.com>, Takashi Iwai <tiwai@...e.com>,
Dan Williams <dan.j.williams@...el.com>,
Russell King <rmk+kernel@....linux.org.uk>,
Laurent Pinchart <renesas@...asonboard.com>,
Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>,
Qiao Zhou <zhouqiao@...vell.com>,
Shengjiu Wang <shengjiu.wang@...escale.com>,
Matt Campbell <mcampbell@...tope.com>,
Jonah Petri <jpetri@...tope.com>,
dmaengine <dmaengine@...r.kernel.org>,
alsa-devel@...a-project.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] dmaengine: Add transfer termination synchronization support
On Tue, Oct 20, 2015 at 12:46 PM, Lars-Peter Clausen <lars@...afoo.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.
> +
> + ret = dmaengine_terminate_async(chan);
> + if (ret)
> + return ret;
> +
> + dmaengine_synchronize(chan);
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists