linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
@ 2009-03-06 11:07 Atsushi Nemoto
  2009-03-11  8:34 ` Sosnowski, Maciej
  2009-03-16 20:39 ` Dan Williams
  0 siblings, 2 replies; 7+ messages in thread
From: Atsushi Nemoto @ 2009-03-06 11:07 UTC (permalink / raw)
  To: Dan Williams; +Cc: Maciej Sosnowski, linux-kernel

Currently dma_request_channel() set DMA_PRIVATE capability but never
clear it.  So if a public channel was once grabbed by
dma_request_channel(), the device stay PRIVATE forever.  Add
privatecnt member to dma_device to correctly revert it.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 drivers/dma/dmaengine.c   |    8 ++++++++
 include/linux/dmaengine.h |    9 +++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 280a9d2..14be8fa 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -507,6 +507,7 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
 			 * published in the general-purpose allocator
 			 */
 			dma_cap_set(DMA_PRIVATE, device->cap_mask);
+			device->privatecnt++;
 			err = dma_chan_get(chan);
 
 			if (err == -ENODEV) {
@@ -518,6 +519,8 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
 				       dma_chan_name(chan), err);
 			else
 				break;
+			if (--device->privatecnt == 0)
+				dma_cap_clear(DMA_PRIVATE, device->cap_mask);
 			chan->private = NULL;
 			chan = NULL;
 		}
@@ -537,6 +540,9 @@ void dma_release_channel(struct dma_chan *chan)
 	WARN_ONCE(chan->client_count != 1,
 		  "chan reference count %d != 1\n", chan->client_count);
 	dma_chan_put(chan);
+	/* drop PRIVATE cap enabled by __dma_request_channel() */
+	if (--chan->device->privatecnt == 0)
+		dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
 	chan->private = NULL;
 	mutex_unlock(&dma_list_mutex);
 }
@@ -701,6 +707,8 @@ int dma_async_device_register(struct dma_device *device)
 			}
 		}
 	list_add_tail_rcu(&device->global_node, &dma_device_list);
+	if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
+		chan->device->privatecnt++;	/* Always private */
 	dma_channel_rebalance();
 	mutex_unlock(&dma_list_mutex);
 
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index f041384..f834fa1 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -209,6 +209,7 @@ struct dma_async_tx_descriptor {
 /**
  * struct dma_device - info on the entity supplying DMA services
  * @chancnt: how many DMA channels are supported
+ * @privatecnt: how many DMA channels are requested by dma_request_channel
  * @channels: the list of struct dma_chan
  * @global_node: list_head for global dma_device_list
  * @cap_mask: one or more dma_capability flags
@@ -232,6 +233,7 @@ struct dma_async_tx_descriptor {
 struct dma_device {
 
 	unsigned int chancnt;
+	unsigned int privatecnt;
 	struct list_head channels;
 	struct list_head global_node;
 	dma_cap_mask_t  cap_mask;
@@ -342,6 +344,13 @@ __dma_cap_set(enum dma_transaction_type tx_type, dma_cap_mask_t *dstp)
 	set_bit(tx_type, dstp->bits);
 }
 
+#define dma_cap_clear(tx, mask) __dma_cap_clear((tx), &(mask))
+static inline void
+__dma_cap_clear(enum dma_transaction_type tx_type, dma_cap_mask_t *dstp)
+{
+	clear_bit(tx_type, dstp->bits);
+}
+
 #define dma_cap_zero(mask) __dma_cap_zero(&(mask))
 static inline void __dma_cap_zero(dma_cap_mask_t *dstp)
 {
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-06 11:07 [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery Atsushi Nemoto
@ 2009-03-11  8:34 ` Sosnowski, Maciej
  2009-03-16 20:39 ` Dan Williams
  1 sibling, 0 replies; 7+ messages in thread
From: Sosnowski, Maciej @ 2009-03-11  8:34 UTC (permalink / raw)
  To: Atsushi Nemoto, Williams, Dan J; +Cc: linux-kernel

Atsushi Nemoto wrote:
> Currently dma_request_channel() set DMA_PRIVATE capability but never
> clear it.  So if a public channel was once grabbed by
> dma_request_channel(), the device stay PRIVATE forever.  Add
> privatecnt member to dma_device to correctly revert it.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---

I think it's a good idea and the patch looks fine to me.

Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-06 11:07 [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery Atsushi Nemoto
  2009-03-11  8:34 ` Sosnowski, Maciej
@ 2009-03-16 20:39 ` Dan Williams
  2009-03-25  9:42   ` Atsushi Nemoto
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Williams @ 2009-03-16 20:39 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: Maciej Sosnowski, linux-kernel

On Fri, Mar 6, 2009 at 4:07 AM, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> Currently dma_request_channel() set DMA_PRIVATE capability but never
> clear it.  So if a public channel was once grabbed by
> dma_request_channel(), the device stay PRIVATE forever.  Add
> privatecnt member to dma_device to correctly revert it.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---

This looks good to me.  Please rebase it on top of the 'next' branch
of the async_tx tree[1] and I will queue it for -next.

Thanks,
Dan

http://git.kernel.org/?p=linux/kernel/git/djbw/async_tx.git;a=shortlog;h=next

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-16 20:39 ` Dan Williams
@ 2009-03-25  9:42   ` Atsushi Nemoto
  2009-03-25 16:27     ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2009-03-25  9:42 UTC (permalink / raw)
  To: dan.j.williams; +Cc: maciej.sosnowski, linux-kernel

On Mon, 16 Mar 2009 13:39:49 -0700, Dan Williams <dan.j.williams@intel.com> wrote:
> > Currently dma_request_channel() set DMA_PRIVATE capability but never
> > clear it.  So if a public channel was once grabbed by
> > dma_request_channel(), the device stay PRIVATE forever.  Add
> > privatecnt member to dma_device to correctly revert it.
> >
> > Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> > ---
> 
> This looks good to me.  Please rebase it on top of the 'next' branch
> of the async_tx tree[1] and I will queue it for -next.
> 
> Thanks,
> Dan
> 
> http://git.kernel.org/?p=linux/kernel/git/djbw/async_tx.git;a=shortlog;h=next

Sorry, I have missed this mail.  I will rebase it, but while the
'next' branch of async_tx tree lacks commit 287d85 ("atmel-mci: fix
initialization of dma slave data"), rebasing will cause another
conflict with mainline.  What should I do?

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-25  9:42   ` Atsushi Nemoto
@ 2009-03-25 16:27     ` Dan Williams
  2009-03-26 11:44       ` Atsushi Nemoto
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Williams @ 2009-03-25 16:27 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: maciej.sosnowski, linux-kernel

On Wed, Mar 25, 2009 at 2:42 AM, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> On Mon, 16 Mar 2009 13:39:49 -0700, Dan Williams <dan.j.williams@intel.com> wrote:
>> > Currently dma_request_channel() set DMA_PRIVATE capability but never
>> > clear it.  So if a public channel was once grabbed by
>> > dma_request_channel(), the device stay PRIVATE forever.  Add
>> > privatecnt member to dma_device to correctly revert it.
>> >
>> > Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>> > ---
>>
>> This looks good to me.  Please rebase it on top of the 'next' branch
>> of the async_tx tree[1] and I will queue it for -next.
>>
>> Thanks,
>> Dan
>>
>> http://git.kernel.org/?p=linux/kernel/git/djbw/async_tx.git;a=shortlog;h=next
>
> Sorry, I have missed this mail.  I will rebase it, but while the
> 'next' branch of async_tx tree lacks commit 287d85 ("atmel-mci: fix
> initialization of dma slave data"), rebasing will cause another
> conflict with mainline.  What should I do?

I have updated the 'next' branch to include this commit.

Thanks,
Dan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-25 16:27     ` Dan Williams
@ 2009-03-26 11:44       ` Atsushi Nemoto
  2009-03-26 17:02         ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2009-03-26 11:44 UTC (permalink / raw)
  To: dan.j.williams; +Cc: maciej.sosnowski, linux-kernel

On Wed, 25 Mar 2009 09:27:27 -0700, Dan Williams <dan.j.williams@intel.com> wrote:
> >> > Currently dma_request_channel() set DMA_PRIVATE capability but never
> >> > clear it.  So if a public channel was once grabbed by
> >> > dma_request_channel(), the device stay PRIVATE forever.  Add
> >> > privatecnt member to dma_device to correctly revert it.
> >> >
> >> > Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> >>
> >> This looks good to me.  Please rebase it on top of the 'next' branch
> >> of the async_tx tree[1] and I will queue it for -next.
> >>
> > Sorry, I have missed this mail.  I will rebase it, but while the
> > 'next' branch of async_tx tree lacks commit 287d85 ("atmel-mci: fix
> > initialization of dma slave data"), rebasing will cause another
> > conflict with mainline.  What should I do?
> 
> I have updated the 'next' branch to include this commit.

Thanks.  And now the patch can be applied using git-am as is.
Should I rebase and send again?

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery
  2009-03-26 11:44       ` Atsushi Nemoto
@ 2009-03-26 17:02         ` Dan Williams
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2009-03-26 17:02 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: maciej.sosnowski, linux-kernel

On Thu, Mar 26, 2009 at 4:44 AM, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> Thanks.  And now the patch can be applied using git-am as is.
> Should I rebase and send again?

No need, it's now applied.

Thanks,
Dan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-03-26 17:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-06 11:07 [PATCH] dmaengine: Add privatecnt to revert DMA_PRIVATE propery Atsushi Nemoto
2009-03-11  8:34 ` Sosnowski, Maciej
2009-03-16 20:39 ` Dan Williams
2009-03-25  9:42   ` Atsushi Nemoto
2009-03-25 16:27     ` Dan Williams
2009-03-26 11:44       ` Atsushi Nemoto
2009-03-26 17:02         ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).