lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120107192112.GB13181@n2100.arm.linux.org.uk>
Date:	Sat, 7 Jan 2012 19:21:12 +0000
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	David Brown <davidb@...eaurora.org>
Cc:	Daniel Walker <dwalker@...o99.com>,
	Ravi Kumar V <kumarrav@...eaurora.org>, vinod.koul@...el.com,
	dan.j.williams@...el.com, arnd@...db.de,
	linux-arch@...r.kernel.org, bryanh@...eaurora.org,
	tsoni@...lcomm.com, johlstei@...lcomm.com,
	linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 2/2] msm: DMAEngine: Add DMAEngine driver based on
	old MSM DMA APIs

On Sat, Jan 07, 2012 at 10:54:43AM -0800, David Brown wrote:
> On Fri, Jan 06, 2012 at 05:59:29PM -0800, Daniel Walker wrote:
> 
> > > diff --git a/drivers/dma/msm-dma.c b/drivers/dma/msm-dma.c
> > > new file mode 100644
> > > index 0000000..51d9a2b
> > > --- /dev/null
> > > +++ b/drivers/dma/msm-dma.c
> > > ...
> > > +static void msm_chan_desc_cleanup(struct msm_dma_chan *chan)
> > > +{
> > > +	struct msm_dma_desc_sw *desc, *_desc;
> > > +	unsigned long flags;
> > > +
> > > +	dev_dbg(chan->dev, "Cleaning completed descriptor of channel %d\n",
> > > +							chan->chan_id);
> > > +	spin_lock_irqsave(&chan->lock, flags);
> > > +
> > > +	list_for_each_entry_safe(desc, _desc, &chan->active_list, node) {
> > > +		dma_async_tx_callback callback;
> > > +		void *callback_param;
> > > +
> > > +		if (msm_dma_desc_status(chan, desc) == DMA_IN_PROGRESS)
> > > +			break;
> > > +
> > > +		/* Remove from the list of running transactions */
> > > +		list_del(&desc->node);
> > > +
> > > +		/* Run the link descriptor callback function */
> > > +		callback = desc->async_tx.callback;
> > > +		callback_param = desc->async_tx.callback_param;
> > > +		if (callback) {
> > > +			spin_unlock_irqrestore(&chan->lock, flags);
> > > +			callback(callback_param);
> > 
> > Are you sure unlocking here is safe? at_hdmac.c holds the lock the
> > entire time, and fsldma.c deletes the entire list, then runs the
> > operations.
> 
> Good catch.
> 
> According to a comment in at_hdmac.c, it is safe to hold the lock
> while calling the callbacks, so that's probably the easiest solution.
> I suspect that you've got something in another driver expecting the
> lock to be released, and that might have to be changed.

It is _not_ safe to hold the lock while calling callbacks.

Please refer to the DMA engine documentation, found here:

Documentation/dmaengine.txt

section 3:

   Note:
        Although the async_tx API specifies that completion callback
        routines cannot submit any new operations, this is not the
        case for slave/cyclic DMA.

        For slave DMA, the subsequent transaction may not be available
        for submission prior to callback function being invoked, so
        slave DMA callbacks are permitted to prepare and submit a new
        transaction.

        For cyclic DMA, a callback function may wish to terminate the
        DMA via dmaengine_terminate_all().

*       Therefore, it is important that DMA engine drivers drop any
*       locks before calling the callback function which may cause a
*       deadlock.

        Note that callbacks will always be invoked from the DMA
        engines tasklet, never from interrupt context.

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ