diff mbox

dma:mmp_tdma: get sram pool through device tree

Message ID 1386922471-19951-2-git-send-email-nhcao@marvell.com (mailing list archive)
State Accepted
Delegated to: Vinod Koul
Headers show

Commit Message

Nenghua Cao Dec. 13, 2013, 8:14 a.m. UTC
Support to get sram pool from generic device tree binding. The
existing way of get sram poll, directly call sram_get_gpool(), still
work here.

Signed-off-by: Nenghua Cao <nhcao@marvell.com>
---
 drivers/dma/mmp_tdma.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

Comments

Zhangfei Gao Dec. 14, 2013, 5:14 a.m. UTC | #1
Thanks for the patch.

On Fri, Dec 13, 2013 at 4:14 PM, Nenghua Cao <nhcao@marvell.com> wrote:
>     Support to get sram pool from generic device tree binding. The
> existing way of get sram poll, directly call sram_get_gpool(), still
> work here.
>
> Signed-off-by: Nenghua Cao <nhcao@marvell.com>

Acked-by: Zhangfei Gao <zhangfei.gao@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nenghua Cao Jan. 8, 2014, 6:54 a.m. UTC | #2
On 12/14/2013 01:14 PM, Zhangfei Gao wrote:
> Thanks for the patch.
> 
> On Fri, Dec 13, 2013 at 4:14 PM, Nenghua Cao <nhcao@marvell.com> wrote:
>>     Support to get sram pool from generic device tree binding. The
>> existing way of get sram poll, directly call sram_get_gpool(), still
>> work here.
>>
>> Signed-off-by: Nenghua Cao <nhcao@marvell.com>
> 
> Acked-by: Zhangfei Gao <zhangfei.gao@gmail.com>
> 
Hi, Dan and Vinod:

       Do you have any comments about this patch? Thanks!
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul Jan. 9, 2014, 12:18 p.m. UTC | #3
On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
>     Support to get sram pool from generic device tree binding. The
> existing way of get sram poll, directly call sram_get_gpool(), still
> work here.
I got a conflict while applying this patch, what was this generated on?
Applied now though..

Also pls dont send cover letter for single patches

--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul Jan. 9, 2014, 12:39 p.m. UTC | #4
On Thu, Jan 09, 2014 at 09:42:02PM +0800, Nenghua Cao wrote:
> On 01/09/2014 08:18 PM, Vinod Koul wrote:
> > On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
> >>     Support to get sram pool from generic device tree binding. The
> >> existing way of get sram poll, directly call sram_get_gpool(), still
> >> work here.
> > I got a conflict while applying this patch, what was this generated on?
> > Applied now though..
> > 
> Based on git git://git.infradead.org/users/vkoul/slave-dma.git
> (slave-dma) branch::master. Is it wrong?
next or for-linus is better. Master reflects the current linus master I have
rebased teh tree on. Patches are in next & for-linus.

--
~Vinod
> 
> > Also pls dont send cover letter for single patches
> > 
> Got it. Thanks!
> > --
> > ~Vinod
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nenghua Cao Jan. 9, 2014, 1:42 p.m. UTC | #5
On 01/09/2014 08:18 PM, Vinod Koul wrote:
> On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
>>     Support to get sram pool from generic device tree binding. The
>> existing way of get sram poll, directly call sram_get_gpool(), still
>> work here.
> I got a conflict while applying this patch, what was this generated on?
> Applied now though..
> 
Based on git git://git.infradead.org/users/vkoul/slave-dma.git
(slave-dma) branch::master. Is it wrong?

> Also pls dont send cover letter for single patches
> 
Got it. Thanks!
> --
> ~Vinod
> 

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nenghua Cao Jan. 9, 2014, 1:47 p.m. UTC | #6
On 01/09/2014 08:39 PM, Vinod Koul wrote:
> On Thu, Jan 09, 2014 at 09:42:02PM +0800, Nenghua Cao wrote:
>> On 01/09/2014 08:18 PM, Vinod Koul wrote:
>>> On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
>>>>     Support to get sram pool from generic device tree binding. The
>>>> existing way of get sram poll, directly call sram_get_gpool(), still
>>>> work here.
>>> I got a conflict while applying this patch, what was this generated on?
>>> Applied now though..
>>>
>> Based on git git://git.infradead.org/users/vkoul/slave-dma.git
>> (slave-dma) branch::master. Is it wrong?
> next or for-linus is better. Master reflects the current linus master I have
> rebased teh tree on. Patches are in next & for-linus.
> 
Got it. Thanks for your work.
> --
> ~Vinod
>>
>>> Also pls dont send cover letter for single patches
>>>
>> Got it. Thanks!
>>> --
>>> ~Vinod
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Williams Jan. 9, 2014, 4:52 p.m. UTC | #7
On Thu, Jan 9, 2014 at 5:47 AM, Nenghua Cao <nhcao@marvell.com> wrote:
> On 01/09/2014 08:39 PM, Vinod Koul wrote:
>> On Thu, Jan 09, 2014 at 09:42:02PM +0800, Nenghua Cao wrote:
>>> On 01/09/2014 08:18 PM, Vinod Koul wrote:
>>>> On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
>>>>>     Support to get sram pool from generic device tree binding. The
>>>>> existing way of get sram poll, directly call sram_get_gpool(), still
>>>>> work here.
>>>> I got a conflict while applying this patch, what was this generated on?
>>>> Applied now though..
>>>>
>>> Based on git git://git.infradead.org/users/vkoul/slave-dma.git
>>> (slave-dma) branch::master. Is it wrong?
>> next or for-linus is better. Master reflects the current linus master I have
>> rebased teh tree on. Patches are in next & for-linus.
>>
> Got it. Thanks for your work.

Nenghua, please see the discussion for the last proposal to change
this [1].  I had a comment about making sure that converting to
of_get_named_gen_pool() did not turn a compile time error into a
runtime error.  The code that registers the sram pool needs to be
selected or depended on by CONFIG_MMP_TDMA.

[1]: https://patchwork.kernel.org/patch/3275281/
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nenghua Cao Jan. 17, 2014, 11:59 a.m. UTC | #8
On 01/10/2014 12:52 AM, Dan Williams wrote:
> On Thu, Jan 9, 2014 at 5:47 AM, Nenghua Cao <nhcao@marvell.com> wrote:
>> On 01/09/2014 08:39 PM, Vinod Koul wrote:
>>> On Thu, Jan 09, 2014 at 09:42:02PM +0800, Nenghua Cao wrote:
>>>> On 01/09/2014 08:18 PM, Vinod Koul wrote:
>>>>> On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
>>>>>>     Support to get sram pool from generic device tree binding. The
>>>>>> existing way of get sram poll, directly call sram_get_gpool(), still
>>>>>> work here.
>>>>> I got a conflict while applying this patch, what was this generated on?
>>>>> Applied now though..
>>>>>
>>>> Based on git git://git.infradead.org/users/vkoul/slave-dma.git
>>>> (slave-dma) branch::master. Is it wrong?
>>> next or for-linus is better. Master reflects the current linus master I have
>>> rebased teh tree on. Patches are in next & for-linus.
>>>
>> Got it. Thanks for your work.
> 
> Nenghua, please see the discussion for the last proposal to change
> this [1].  I had a comment about making sure that converting to
> of_get_named_gen_pool() did not turn a compile time error into a
> runtime error.  The code that registers the sram pool needs to be
> selected or depended on by CONFIG_MMP_TDMA.
> 
> [1]: https://patchwork.kernel.org/patch/3275281/
> 
Dan:

   Until now, I can't open this webpage. I don't understand why
of_get_named_gen_pool should depend on CONFIG_MMP_TDMA?

BR
Nenghua
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul Jan. 20, 2014, 5:58 a.m. UTC | #9
On Fri, Jan 17, 2014 at 07:59:02PM +0800, Nenghua Cao wrote:
> On 01/10/2014 12:52 AM, Dan Williams wrote:
> > On Thu, Jan 9, 2014 at 5:47 AM, Nenghua Cao <nhcao@marvell.com> wrote:
> >> On 01/09/2014 08:39 PM, Vinod Koul wrote:
> >>> On Thu, Jan 09, 2014 at 09:42:02PM +0800, Nenghua Cao wrote:
> >>>> On 01/09/2014 08:18 PM, Vinod Koul wrote:
> >>>>> On Fri, Dec 13, 2013 at 04:14:31PM +0800, Nenghua Cao wrote:
> >>>>>>     Support to get sram pool from generic device tree binding. The
> >>>>>> existing way of get sram poll, directly call sram_get_gpool(), still
> >>>>>> work here.
> >>>>> I got a conflict while applying this patch, what was this generated on?
> >>>>> Applied now though..
> >>>>>
> >>>> Based on git git://git.infradead.org/users/vkoul/slave-dma.git
> >>>> (slave-dma) branch::master. Is it wrong?
> >>> next or for-linus is better. Master reflects the current linus master I have
> >>> rebased teh tree on. Patches are in next & for-linus.
> >>>
> >> Got it. Thanks for your work.
> > 
> > Nenghua, please see the discussion for the last proposal to change
> > this [1].  I had a comment about making sure that converting to
> > of_get_named_gen_pool() did not turn a compile time error into a
> > runtime error.  The code that registers the sram pool needs to be
> > selected or depended on by CONFIG_MMP_TDMA.
> > 
> > [1]: https://patchwork.kernel.org/patch/3275281/
> > 
> Dan:
> 
>    Until now, I can't open this webpage. I don't understand why
> of_get_named_gen_pool should depend on CONFIG_MMP_TDMA?
The above link works fine for me.

IIUC, the of_get_named_gen_pool() will compile but will return an error if
CONFIG_MMP_TDMA is not defined thus giving you a runtime error! So this needs
fix so that we dont come with such issue...

--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index 3ddacc1..d3c57fe 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -126,6 +126,8 @@  struct mmp_tdma_chan {
 	size_t				buf_len;
 	size_t				period_len;
 	size_t				pos;
+
+	struct gen_pool			*pool;
 };
 
 #define TDMA_CHANNEL_NUM 2
@@ -324,7 +326,7 @@  static void mmp_tdma_free_descriptor(struct mmp_tdma_chan *tdmac)
 	struct gen_pool *gpool;
 	int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
 
-	gpool = sram_get_gpool("asram");
+	gpool = tdmac->pool;
 	if (tdmac->desc_arr)
 		gen_pool_free(gpool, (unsigned long)tdmac->desc_arr,
 				size);
@@ -374,7 +376,7 @@  struct mmp_tdma_desc *mmp_tdma_alloc_descriptor(struct mmp_tdma_chan *tdmac)
 	struct gen_pool *gpool;
 	int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
 
-	gpool = sram_get_gpool("asram");
+	gpool = tdmac->pool;
 	if (!gpool)
 		return NULL;
 
@@ -505,7 +507,8 @@  static int mmp_tdma_remove(struct platform_device *pdev)
 }
 
 static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
-						int idx, int irq, int type)
+					int idx, int irq,
+					int type, struct gen_pool *pool)
 {
 	struct mmp_tdma_chan *tdmac;
 
@@ -526,6 +529,7 @@  static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
 	tdmac->chan.device = &tdev->device;
 	tdmac->idx	   = idx;
 	tdmac->type	   = type;
+	tdmac->pool	   = pool;
 	tdmac->reg_base	   = (unsigned long)tdev->base + idx * 4;
 	tdmac->status = DMA_COMPLETE;
 	tdev->tdmac[tdmac->idx] = tdmac;
@@ -553,6 +557,7 @@  static int mmp_tdma_probe(struct platform_device *pdev)
 	int i, ret;
 	int irq = 0, irq_num = 0;
 	int chan_num = TDMA_CHANNEL_NUM;
+	struct gen_pool *pool;
 
 	of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
 	if (of_id)
@@ -579,6 +584,15 @@  static int mmp_tdma_probe(struct platform_device *pdev)
 
 	INIT_LIST_HEAD(&tdev->device.channels);
 
+	if (pdev->dev.of_node)
+		pool = of_get_named_gen_pool(pdev->dev.of_node, "asram", 0);
+	else
+		pool = sram_get_gpool("asram");
+	if (!pool) {
+		dev_err(&pdev->dev, "asram pool not available\n");
+		return -ENOMEM;
+	}
+
 	if (irq_num != chan_num) {
 		irq = platform_get_irq(pdev, 0);
 		ret = devm_request_irq(&pdev->dev, irq,
@@ -590,7 +604,7 @@  static int mmp_tdma_probe(struct platform_device *pdev)
 	/* initialize channel parameters */
 	for (i = 0; i < chan_num; i++) {
 		irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i);
-		ret = mmp_tdma_chan_init(tdev, i, irq, type);
+		ret = mmp_tdma_chan_init(tdev, i, irq, type, pool);
 		if (ret)
 			return ret;
 	}