linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
@ 2017-01-02 10:07 Peter Ujfalusi
  2017-01-02 10:09 ` Peter Ujfalusi
  2017-01-02 19:13 ` Aaro Koskinen
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2017-01-02 10:07 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, aaro.koskinen, tony, stable

The original patch did not done what it was supposed to be doing and even
worst it broke legacy boot (OMAP1).

The lch_map size should be the number of available logical channels in sDMA
and the od->dma_requests should store the number of available DMA request
lines usable in sDMA.

In legacy mode we do not have a way to get the DMA request count, in that
case we use OMAP_SDMA_REQUESTS (127), despite the fact that OMAP1510 have
only 31 DMA request line.

Fixes: 2d1a9a946fae ("dmaengine: omap-dma: Dynamically allocate memory for lch_map")
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: stable@vger.kernel.org   # v4.9
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/omap-dma.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index ac68666cd3f4..4ad101a47e0a 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -1452,6 +1452,7 @@ static int omap_dma_probe(struct platform_device *pdev)
 	struct omap_dmadev *od;
 	struct resource *res;
 	int rc, i, irq;
+	u32 lch_count;
 
 	od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL);
 	if (!od)
@@ -1494,20 +1495,31 @@ static int omap_dma_probe(struct platform_device *pdev)
 	spin_lock_init(&od->lock);
 	spin_lock_init(&od->irq_lock);
 
-	if (!pdev->dev.of_node) {
-		od->dma_requests = od->plat->dma_attr->lch_count;
-		if (unlikely(!od->dma_requests))
-			od->dma_requests = OMAP_SDMA_REQUESTS;
-	} else if (of_property_read_u32(pdev->dev.of_node, "dma-requests",
-					&od->dma_requests)) {
+	/* Number of DMA requests */
+	od->dma_requests = OMAP_SDMA_REQUESTS;
+	if (pdev->dev.of_node && of_property_read_u32(pdev->dev.of_node,
+						      "dma-requests",
+						      &od->dma_requests)) {
 		dev_info(&pdev->dev,
 			 "Missing dma-requests property, using %u.\n",
 			 OMAP_SDMA_REQUESTS);
-		od->dma_requests = OMAP_SDMA_REQUESTS;
 	}
 
-	od->lch_map = devm_kcalloc(&pdev->dev, od->dma_requests,
-				   sizeof(*od->lch_map), GFP_KERNEL);
+	/* Number of available logical channels */
+	if (!pdev->dev.of_node) {
+		lch_count = od->plat->dma_attr->lch_count;
+		if (unlikely(!lch_count))
+			lch_count = OMAP_SDMA_CHANNELS;
+	} else if (of_property_read_u32(pdev->dev.of_node, "dma-channels",
+					&lch_count)) {
+		dev_info(&pdev->dev,
+			 "Missing dma-channels property, using %u.\n",
+			 OMAP_SDMA_CHANNELS);
+		lch_count = OMAP_SDMA_CHANNELS;
+	}
+
+	od->lch_map = devm_kcalloc(&pdev->dev, lch_count, sizeof(*od->lch_map),
+				   GFP_KERNEL);
 	if (!od->lch_map)
 		return -ENOMEM;
 
-- 
2.11.0

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

* Re: [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
  2017-01-02 10:07 [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation Peter Ujfalusi
@ 2017-01-02 10:09 ` Peter Ujfalusi
  2017-01-02 10:21   ` Vinod Koul
  2017-01-02 19:13 ` Aaro Koskinen
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Ujfalusi @ 2017-01-02 10:09 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, aaro.koskinen, tony, stable

I have typo in the subject line: s/alocation/allocation ...

Vinod: can you fix it up or should I resend?

-- 
Péter

On 01/02/2017 12:07 PM, Peter Ujfalusi wrote:
> The original patch did not done what it was supposed to be doing and even
> worst it broke legacy boot (OMAP1).
> 
> The lch_map size should be the number of available logical channels in sDMA
> and the od->dma_requests should store the number of available DMA request
> lines usable in sDMA.
> 
> In legacy mode we do not have a way to get the DMA request count, in that
> case we use OMAP_SDMA_REQUESTS (127), despite the fact that OMAP1510 have
> only 31 DMA request line.
> 
> Fixes: 2d1a9a946fae ("dmaengine: omap-dma: Dynamically allocate memory for lch_map")
> Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
> Cc: stable@vger.kernel.org   # v4.9
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  drivers/dma/omap-dma.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
> index ac68666cd3f4..4ad101a47e0a 100644
> --- a/drivers/dma/omap-dma.c
> +++ b/drivers/dma/omap-dma.c
> @@ -1452,6 +1452,7 @@ static int omap_dma_probe(struct platform_device *pdev)
>  	struct omap_dmadev *od;
>  	struct resource *res;
>  	int rc, i, irq;
> +	u32 lch_count;
>  
>  	od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL);
>  	if (!od)
> @@ -1494,20 +1495,31 @@ static int omap_dma_probe(struct platform_device *pdev)
>  	spin_lock_init(&od->lock);
>  	spin_lock_init(&od->irq_lock);
>  
> -	if (!pdev->dev.of_node) {
> -		od->dma_requests = od->plat->dma_attr->lch_count;
> -		if (unlikely(!od->dma_requests))
> -			od->dma_requests = OMAP_SDMA_REQUESTS;
> -	} else if (of_property_read_u32(pdev->dev.of_node, "dma-requests",
> -					&od->dma_requests)) {
> +	/* Number of DMA requests */
> +	od->dma_requests = OMAP_SDMA_REQUESTS;
> +	if (pdev->dev.of_node && of_property_read_u32(pdev->dev.of_node,
> +						      "dma-requests",
> +						      &od->dma_requests)) {
>  		dev_info(&pdev->dev,
>  			 "Missing dma-requests property, using %u.\n",
>  			 OMAP_SDMA_REQUESTS);
> -		od->dma_requests = OMAP_SDMA_REQUESTS;
>  	}
>  
> -	od->lch_map = devm_kcalloc(&pdev->dev, od->dma_requests,
> -				   sizeof(*od->lch_map), GFP_KERNEL);
> +	/* Number of available logical channels */
> +	if (!pdev->dev.of_node) {
> +		lch_count = od->plat->dma_attr->lch_count;
> +		if (unlikely(!lch_count))
> +			lch_count = OMAP_SDMA_CHANNELS;
> +	} else if (of_property_read_u32(pdev->dev.of_node, "dma-channels",
> +					&lch_count)) {
> +		dev_info(&pdev->dev,
> +			 "Missing dma-channels property, using %u.\n",
> +			 OMAP_SDMA_CHANNELS);
> +		lch_count = OMAP_SDMA_CHANNELS;
> +	}
> +
> +	od->lch_map = devm_kcalloc(&pdev->dev, lch_count, sizeof(*od->lch_map),
> +				   GFP_KERNEL);
>  	if (!od->lch_map)
>  		return -ENOMEM;
>  
> 

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

* Re: [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
  2017-01-02 10:09 ` Peter Ujfalusi
@ 2017-01-02 10:21   ` Vinod Koul
  2017-01-02 10:23     ` Peter Ujfalusi
  0 siblings, 1 reply; 6+ messages in thread
From: Vinod Koul @ 2017-01-02 10:21 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: dan.j.williams, dmaengine, linux-kernel, linux-omap,
	aaro.koskinen, tony, stable

On Mon, Jan 02, 2017 at 12:09:03PM +0200, Peter Ujfalusi wrote:
> I have typo in the subject line: s/alocation/allocation ...
> 
> Vinod: can you fix it up or should I resend?

Either way is fine :)


-- 
~Vinod

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

* Re: [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
  2017-01-02 10:21   ` Vinod Koul
@ 2017-01-02 10:23     ` Peter Ujfalusi
  2017-01-03  3:41       ` Vinod Koul
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Ujfalusi @ 2017-01-02 10:23 UTC (permalink / raw)
  To: Vinod Koul
  Cc: dan.j.williams, dmaengine, linux-kernel, linux-omap,
	aaro.koskinen, tony, stable



On 01/02/2017 12:21 PM, Vinod Koul wrote:
> On Mon, Jan 02, 2017 at 12:09:03PM +0200, Peter Ujfalusi wrote:
>> I have typo in the subject line: s/alocation/allocation ...
>>
>> Vinod: can you fix it up or should I resend?
> 
> Either way is fine :)

Let's wait for Aaro to test it and I will resend after that.

-- 
Péter

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

* Re: [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
  2017-01-02 10:07 [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation Peter Ujfalusi
  2017-01-02 10:09 ` Peter Ujfalusi
@ 2017-01-02 19:13 ` Aaro Koskinen
  1 sibling, 0 replies; 6+ messages in thread
From: Aaro Koskinen @ 2017-01-02 19:13 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: vinod.koul, dan.j.williams, dmaengine, linux-kernel, linux-omap,
	tony, stable

Hi,

On Mon, Jan 02, 2017 at 12:07:37PM +0200, Peter Ujfalusi wrote:
> The original patch did not done what it was supposed to be doing and even
> worst it broke legacy boot (OMAP1).
> 
> The lch_map size should be the number of available logical channels in sDMA
> and the od->dma_requests should store the number of available DMA request
> lines usable in sDMA.
> 
> In legacy mode we do not have a way to get the DMA request count, in that
> case we use OMAP_SDMA_REQUESTS (127), despite the fact that OMAP1510 have
> only 31 DMA request line.
> 
> Fixes: 2d1a9a946fae ("dmaengine: omap-dma: Dynamically allocate memory for lch_map")
> Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
> Cc: stable@vger.kernel.org   # v4.9
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>

Thanks,

A.

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

* Re: [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation
  2017-01-02 10:23     ` Peter Ujfalusi
@ 2017-01-03  3:41       ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2017-01-03  3:41 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: dan.j.williams, dmaengine, linux-kernel, linux-omap,
	aaro.koskinen, tony, stable

On Mon, Jan 02, 2017 at 12:23:45PM +0200, Peter Ujfalusi wrote:
> 
> 
> On 01/02/2017 12:21 PM, Vinod Koul wrote:
> > On Mon, Jan 02, 2017 at 12:09:03PM +0200, Peter Ujfalusi wrote:
> >> I have typo in the subject line: s/alocation/allocation ...
> >>
> >> Vinod: can you fix it up or should I resend?
> > 
> > Either way is fine :)
> 
> Let's wait for Aaro to test it and I will resend after that.

I have applied it after fixing the typo

-- 
~Vinod

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

end of thread, other threads:[~2017-01-03  3:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-02 10:07 [PATCH] dmaengine: omap-dma: Fix dynamic lch_map alocation Peter Ujfalusi
2017-01-02 10:09 ` Peter Ujfalusi
2017-01-02 10:21   ` Vinod Koul
2017-01-02 10:23     ` Peter Ujfalusi
2017-01-03  3:41       ` Vinod Koul
2017-01-02 19:13 ` Aaro Koskinen

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