All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brown <davidb@codeaurora.org>
To: Daniel Walker <dwalker@fifo99.com>
Cc: Ravi Kumar V <kumarrav@codeaurora.org>,
	vinod.koul@intel.com, dan.j.williams@intel.com, arnd@arndb.de,
	linux-arch@vger.kernel.org, bryanh@codeaurora.org,
	linux@arm.linux.org.uk, tsoni@qualcomm.com,
	johlstei@qualcomm.com, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/2] msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs
Date: Sat, 7 Jan 2012 10:54:43 -0800	[thread overview]
Message-ID: <20120107185443.GA19216@codeaurora.org> (raw)
In-Reply-To: <1325901569.10425.14.camel@m0nster>

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.

I do think the way fsldma.c does it is cleaner, though, since it
allows the lock to be released for longer periods of times.

In either case, it can't be releasing a lock in the middle of a loop
like this.

David

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

WARNING: multiple messages have this Message-ID (diff)
From: davidb@codeaurora.org (David Brown)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/2] msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs
Date: Sat, 7 Jan 2012 10:54:43 -0800	[thread overview]
Message-ID: <20120107185443.GA19216@codeaurora.org> (raw)
In-Reply-To: <1325901569.10425.14.camel@m0nster>

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.

I do think the way fsldma.c does it is cleaner, though, since it
allows the lock to be released for longer periods of times.

In either case, it can't be releasing a lock in the middle of a loop
like this.

David

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2012-01-07 18:54 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06 12:47 [PATCH v2 0/2] Add Qualcomm MSM ADM DMAEngine driver Ravi Kumar V
2012-01-06 12:47 ` Ravi Kumar V
2012-01-06 12:47 ` [PATCH v2 1/2] dmaengine: Add support for per xfer specific privatedata & box dma Ravi Kumar V
2012-01-06 12:47   ` Ravi Kumar V
2012-01-07  0:02   ` David Brown
2012-01-07  0:02     ` David Brown
2012-01-17 13:53   ` Vinod Koul
2012-01-17 13:53     ` Vinod Koul
2012-01-20 12:33     ` Ravi Kumar V
2012-01-20 12:33       ` Ravi Kumar V
2012-01-06 12:47 ` [PATCH v2 2/2] msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs Ravi Kumar V
2012-01-06 12:47   ` Ravi Kumar V
2012-01-07  1:59   ` Daniel Walker
2012-01-07  1:59     ` Daniel Walker
2012-01-07  1:59     ` Daniel Walker
2012-01-07 18:54     ` David Brown [this message]
2012-01-07 18:54       ` David Brown
2012-01-07 19:21       ` Russell King - ARM Linux
2012-01-07 19:21         ` Russell King - ARM Linux
2012-01-08  0:13         ` Daniel Walker
2012-01-08  0:13           ` Daniel Walker
2012-01-08  0:21           ` Russell King - ARM Linux
2012-01-08  0:21             ` Russell King - ARM Linux
2012-01-09 11:11     ` Ravi Kumar V
2012-01-09 11:11       ` Ravi Kumar V
2012-01-17  6:26       ` Ravi Kumar V
2012-01-17  6:26         ` Ravi Kumar V
2012-01-17  6:32       ` Ravi Kumar V
2012-01-17  6:32         ` Ravi Kumar V
2012-01-17 14:35     ` Vinod Koul
2012-01-17 14:35       ` Vinod Koul
2012-01-20 12:47       ` Ravi Kumar V
2012-01-20 12:47         ` Ravi Kumar V
2012-01-17 14:31   ` Vinod Koul
2012-01-17 14:31     ` Vinod Koul
2012-01-17 14:31     ` Vinod Koul
2012-01-20 12:46     ` Ravi Kumar V
2012-01-20 12:46       ` Ravi Kumar V
2012-01-17 13:45 ` [PATCH v2 0/2] Add Qualcomm MSM ADM DMAEngine driver Vinod Koul
2012-01-17 13:45   ` Vinod Koul
2012-01-20 12:30   ` Ravi Kumar V
2012-01-20 12:30     ` Ravi Kumar V
2012-01-20 13:31     ` Vinod Koul
2012-01-20 13:31       ` Vinod Koul
2012-01-23 11:11       ` Ravi Kumar V
2012-01-23 11:11         ` Ravi Kumar V
2012-01-23 13:51         ` Vinod Koul
2012-01-23 13:51           ` Vinod Koul
2012-01-25 13:11           ` Ravi Kumar V
2012-01-25 13:11             ` Ravi Kumar V
2012-01-30  7:53             ` Ravi Kumar V
2012-01-30  7:53               ` Ravi Kumar V
2012-01-30  8:15             ` Vinod Koul
2012-01-30  8:15               ` Vinod Koul
2012-01-31  5:59               ` Ravi Kumar V
2012-01-31  5:59                 ` Ravi Kumar V
2012-01-31  6:09                 ` Vinod Koul
2012-01-31  6:09                   ` Vinod Koul
2012-02-01  6:16                   ` Ravi Kumar V
2012-02-01  6:16                     ` Ravi Kumar V
2012-02-01  8:29                     ` Vinod Koul
2012-02-01  8:29                       ` Vinod Koul
2012-02-01  8:29                       ` Vinod Koul
2012-02-01  8:37                       ` Ravi Kumar V
2012-02-01  8:46                         ` Vinod Koul
2012-02-01  9:08                           ` Ravi Kumar V
2012-02-01  9:08                             ` Ravi Kumar V
2012-02-01  8:38                       ` Ravi Kumar V
2012-02-01  8:38                         ` Ravi Kumar V

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=20120107185443.GA19216@codeaurora.org \
    --to=davidb@codeaurora.org \
    --cc=arnd@arndb.de \
    --cc=bryanh@codeaurora.org \
    --cc=dan.j.williams@intel.com \
    --cc=dwalker@fifo99.com \
    --cc=johlstei@qualcomm.com \
    --cc=kumarrav@codeaurora.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tsoni@qualcomm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.