Skip to contentSkip to conversation

dma: of-dma: return error when 'dma-cells' not found

PATCH New Padmavathi Venna 5 participants 12 messages Mar 5, 2013 – Apr 2, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

This patch returns error when 'dma-cells' property not found in the corresponding device node. With out this change there is a crash in the generic dma incompatible platforms.

---

Based on Vinod Koul next branch.

 drivers/dma/of-dma.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/dma/of-dma.c +7 -1
index 69d04d2..46aca0d 100644
@@ -92,6 +92,7 @@ int of_dma_controller_register(struct device_node *np,
 				void *data)
 {
 	struct of_dma	*ofdma;
+	const	 __be32 *ip;
 	int		nbcells;
 
 	if (!np || !of_dma_xlate) {
@@ -103,7 +104,12 @@ int of_dma_controller_register(struct device_node *np,
 	if (!ofdma)
 		return -ENOMEM;
 
-	nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
+	ip = of_get_property(np, "#dma-cells", NULL);
+	if (!ip)
+		return -ENXIO;
+
+	nbcells = be32_to_cpup(ip);
+
 	if (!nbcells) {
 		pr_err("%s: #dma-cells property is missing or invalid\n",
 		       __func__);
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +27 -11
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
 	struct dma_pl330_platdata *pdat;
 	struct dma_pl330_dmac *pdmac;
-	struct dma_pl330_chan *pch;
+	struct dma_pl330_chan *pch, *_p;
 	struct pl330_info *pi;
 	struct dma_device *pd;
 	struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = dma_async_device_register(pd);
 	if (ret) {
 		dev_err(&adev->dev, "unable to register DMAC\n");
-		goto probe_err2;
+		goto probe_err3;
+	}
+
+	if (adev->dev.of_node) {
+		ret = of_dma_controller_register(adev->dev.of_node,
+					 of_dma_pl330_xlate, pdmac);
+		if (ret) {
+			dev_err(&adev->dev,
+			"unable to register DMA to the generic DT DMA helpers\n");
+		}
 	}
 
 	dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
 		pi->pcfg.num_peri, pi->pcfg.num_events);
 
-	ret = of_dma_controller_register(adev->dev.of_node,
-					 of_dma_pl330_xlate, pdmac);
-	if (ret) {
-		dev_err(&adev->dev,
-		"unable to register DMA to the generic DT DMA helpers\n");
-		goto probe_err2;
-	}
-
 	return 0;
+probe_err3:
+	amba_set_drvdata(adev, NULL);
 
+	/* Idle the DMAC */
+	list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+			chan.device_node) {
+
+		/* Remove the channel */
+		list_del(&pch->chan.device_node);
+
+		/* Flush the channel */
+		pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+		pl330_free_chan_resources(&pch->chan);
+	}
 probe_err2:
 	pl330_del(pi);
 probe_err1:
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
 	if (!pdmac)
 		return 0;
 
-	of_dma_controller_free(adev->dev.of_node);
+	if (adev->dev.of_node)
+		of_dma_controller_free(adev->dev.of_node);
 
+	dma_async_device_unregister(&pdmac->ddma);
 	amba_set_drvdata(adev, NULL);
 
 	/* Idle the DMAC */
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

Hi,

Quoted 78 lines · Padmavathi Venna

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +24 -10
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
        struct dma_pl330_platdata *pdat;
        struct dma_pl330_dmac *pdmac;
-       struct dma_pl330_chan *pch;
+       struct dma_pl330_chan *pch, *_p;
        struct pl330_info *pi;
        struct dma_device *pd;
        struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
        ret = dma_async_device_register(pd);
        if (ret) {
                dev_err(&adev->dev, "unable to register DMAC\n");
-               goto probe_err2;
+               goto probe_err3;
+       }
+
+       if (adev->dev.of_node) {
+               ret = of_dma_controller_register(adev->dev.of_node,
+                                        of_dma_pl330_xlate, pdmac);
+               if (ret) {
+                       dev_err(&adev->dev,
+                       "unable to register DMA to the generic DT DMA helpers\n");
+               }
        }
 
        dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
                pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
                pi->pcfg.num_peri, pi->pcfg.num_events);
 
-       ret = of_dma_controller_register(adev->dev.of_node,
-                                        of_dma_pl330_xlate, pdmac);
-       if (ret) {
-               dev_err(&adev->dev,
-               "unable to register DMA to the generic DT DMA helpers\n");
-               goto probe_err2;
-       }
-
        return 0;
+probe_err3:
+       amba_set_drvdata(adev, NULL);
 
+       /* Idle the DMAC */
+       list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+                       chan.device_node) {
+
+               /* Remove the channel */
+               list_del(&pch->chan.device_node);
+
+               /* Flush the channel */
+               pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+               pl330_free_chan_resources(&pch->chan);
+       }
 probe_err2:
        pl330_del(pi);
 probe_err1:

drivers/dma/pl330.c static int pl330_remove(struct amba_device *adev) · line 3043

Quoted 8 lines
drivers/dma/pl330.c +3 -1
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
        if (!pdmac)
                return 0;
 
-       of_dma_controller_free(adev->dev.of_node);
+       if (adev->dev.of_node)
+               of_dma_controller_free(adev->dev.of_node);
 
+       dma_async_device_unregister(&pdmac->ddma);

Any comment on this patch?

Vinod,

Can you please take this patch into your tree?

Quoted 6 lines
drivers/dma/pl330.c +0 -1
        amba_set_drvdata(adev, NULL);
 
        /* Idle the DMAC */
--

1.7.4.4

Thanks
Padma

#3 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

In reply to Padmavathi Venna
Quoted 33 lines · Padmavathi Venna

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +1 -1
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
 	struct dma_pl330_platdata *pdat;
 	struct dma_pl330_dmac *pdmac;
-	struct dma_pl330_chan *pch;
+	struct dma_pl330_chan *pch, *_p;
 	struct pl330_info *pi;
 	struct dma_device *pd;
 	struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = dma_async_device_register(pd);
 	if (ret) {
 		dev_err(&adev->dev, "unable to register DMAC\n");

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 2995

Quoted 10 lines
drivers/dma/pl330.c +9 -1
-		goto probe_err2;
+		goto probe_err3;
+	}
+
+	if (adev->dev.of_node) {
+		ret = of_dma_controller_register(adev->dev.of_node,
+					 of_dma_pl330_xlate, pdmac);
+		if (ret) {
+			dev_err(&adev->dev,
+			"unable to register DMA to the generic DT DMA helpers\n");

Indent?

Quoted 20 lines
drivers/dma/pl330.c +3 -8
+		}
 	}
 
 	dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
 		pi->pcfg.num_peri, pi->pcfg.num_events);
 
-	ret = of_dma_controller_register(adev->dev.of_node,
-					 of_dma_pl330_xlate, pdmac);
-	if (ret) {
-		dev_err(&adev->dev,
-		"unable to register DMA to the generic DT DMA helpers\n");
-		goto probe_err2;
-	}
-
 	return 0;
+probe_err3:
+	amba_set_drvdata(adev, NULL);
 

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 3020

Quoted 10 lines
drivers/dma/pl330.c +10 -0
+	/* Idle the DMAC */
+	list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+			chan.device_node) {
+
+		/* Remove the channel */
+		list_del(&pch->chan.device_node);
+
+		/* Flush the channel */
+		pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+		pl330_free_chan_resources(&pch->chan);

free_chan for error handling in probe?

Quoted 19 lines
drivers/dma/pl330.c +4 -1
+	}
 probe_err2:
 	pl330_del(pi);
 probe_err1:
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
 	if (!pdmac)
 		return 0;
 
-	of_dma_controller_free(adev->dev.of_node);
+	if (adev->dev.of_node)
+		of_dma_controller_free(adev->dev.of_node);
 
+	dma_async_device_unregister(&pdmac->ddma);
 	amba_set_drvdata(adev, NULL);
 
 	/* Idle the DMAC */
Signature · 1 line
1.7.4.4
#4 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

Quoted 6 lines · Vinod Koul
Quoted 5 lines · Padmavathi Venna

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

What's the status on this? It is needed for 3.9 to fix pl330 on highbank.

Rob

Quoted 90 lines
Quoted 28 lines

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +1 -1
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
      struct dma_pl330_platdata *pdat;
      struct dma_pl330_dmac *pdmac;
-     struct dma_pl330_chan *pch;
+     struct dma_pl330_chan *pch, *_p;
      struct pl330_info *pi;
      struct dma_device *pd;
      struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
      ret = dma_async_device_register(pd);
      if (ret) {
              dev_err(&adev->dev, "unable to register DMAC\n");

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 2995

Quoted 10 lines
drivers/dma/pl330.c +9 -1
-             goto probe_err2;
+             goto probe_err3;
+     }
+
+     if (adev->dev.of_node) {
+             ret = of_dma_controller_register(adev->dev.of_node,
+                                      of_dma_pl330_xlate, pdmac);
+             if (ret) {
+                     dev_err(&adev->dev,
+                     "unable to register DMA to the generic DT DMA helpers\n");

Indent?

Quoted 20 lines
drivers/dma/pl330.c +3 -8
+             }
      }
 
      dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
              pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
              pi->pcfg.num_peri, pi->pcfg.num_events);
 
-     ret = of_dma_controller_register(adev->dev.of_node,
-                                      of_dma_pl330_xlate, pdmac);
-     if (ret) {
-             dev_err(&adev->dev,
-             "unable to register DMA to the generic DT DMA helpers\n");
-             goto probe_err2;
-     }
-
      return 0;
+probe_err3:
+     amba_set_drvdata(adev, NULL);
 

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 3020

Quoted 10 lines
drivers/dma/pl330.c +10 -0
+     /* Idle the DMAC */
+     list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+                     chan.device_node) {
+
+             /* Remove the channel */
+             list_del(&pch->chan.device_node);
+
+             /* Flush the channel */
+             pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+             pl330_free_chan_resources(&pch->chan);

free_chan for error handling in probe?

Quoted 19 lines
drivers/dma/pl330.c +4 -2
+     }
 probe_err2:
      pl330_del(pi);
 probe_err1:
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
      if (!pdmac)
              return 0;
 
-     of_dma_controller_free(adev->dev.of_node);
+     if (adev->dev.of_node)
+             of_dma_controller_free(adev->dev.of_node);
 
+     dma_async_device_unregister(&pdmac->ddma);
      amba_set_drvdata(adev, NULL);
 
      /* Idle the DMAC */
--

1.7.4.4

#5 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

Quoted 9 lines · Rob Herring
Quoted 6 lines · Vinod Koul
Quoted 5 lines · Padmavathi Venna

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

What's the status on this? It is needed for 3.9 to fix pl330 on highbank.

Well the status is that submitter has been rude. I had few questions and comments on this patch and they are yet to be addressed.

--
~Vinod

Quoted 93 lines

Rob

Quoted 90 lines
Quoted 28 lines

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +1 -1
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
      struct dma_pl330_platdata *pdat;
      struct dma_pl330_dmac *pdmac;
-     struct dma_pl330_chan *pch;
+     struct dma_pl330_chan *pch, *_p;
      struct pl330_info *pi;
      struct dma_device *pd;
      struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
      ret = dma_async_device_register(pd);
      if (ret) {
              dev_err(&adev->dev, "unable to register DMAC\n");

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 2995

Quoted 10 lines
drivers/dma/pl330.c +9 -1
-             goto probe_err2;
+             goto probe_err3;
+     }
+
+     if (adev->dev.of_node) {
+             ret = of_dma_controller_register(adev->dev.of_node,
+                                      of_dma_pl330_xlate, pdmac);
+             if (ret) {
+                     dev_err(&adev->dev,
+                     "unable to register DMA to the generic DT DMA helpers\n");

Indent?

Quoted 20 lines
drivers/dma/pl330.c +3 -8
+             }
      }
 
      dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
              pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
              pi->pcfg.num_peri, pi->pcfg.num_events);
 
-     ret = of_dma_controller_register(adev->dev.of_node,
-                                      of_dma_pl330_xlate, pdmac);
-     if (ret) {
-             dev_err(&adev->dev,
-             "unable to register DMA to the generic DT DMA helpers\n");
-             goto probe_err2;
-     }
-
      return 0;
+probe_err3:
+     amba_set_drvdata(adev, NULL);
 

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 3020

Quoted 10 lines
drivers/dma/pl330.c +10 -0
+     /* Idle the DMAC */
+     list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+                     chan.device_node) {
+
+             /* Remove the channel */
+             list_del(&pch->chan.device_node);
+
+             /* Flush the channel */
+             pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+             pl330_free_chan_resources(&pch->chan);

free_chan for error handling in probe?

Quoted 19 lines
drivers/dma/pl330.c +4 -2
+     }
 probe_err2:
      pl330_del(pi);
 probe_err1:
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
      if (!pdmac)
              return 0;
 
-     of_dma_controller_free(adev->dev.of_node);
+     if (adev->dev.of_node)
+             of_dma_controller_free(adev->dev.of_node);
 
+     dma_async_device_unregister(&pdmac->ddma);
      amba_set_drvdata(adev, NULL);
 
      /* Idle the DMAC */
--

1.7.4.4

#6 lore raw

PATCH v2 1/1 DMA: PL330: Add check if device tree compatible

Hi Vinod,

I apologies for the delayed reply. Last week I was out of station and no access to mails. I will send another patch addressing your comments.

Thanks
Padma

Quoted 10 lines · Vinod Koul
Quoted 8 lines · Rob Herring
Quoted 6 lines · Vinod Koul
Quoted 5 lines · Padmavathi Venna

This patch register the dma controller with generic dma helpers only in DT case. This also adds some extra error handling in the driver.

Quoted 48 lines
Quoted 1 line

What's the status on this? It is needed for 3.9 to fix pl330 on highbank.

Well the status is that submitter has been rude. I had few questions and comments on this patch and they are yet to be addressed.

--
~Vinod

Quoted 42 lines

Rob

Quoted 39 lines
Quoted 28 lines

---

Based on Vinod Koul next branch.

Changes since V1:
- return silently when of_dma_controller_register fails, as suggested by Arnd.

 drivers/dma/pl330.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)
drivers/dma/pl330.c +1 -1
index 7181531..5dbc594 100644
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 {
      struct dma_pl330_platdata *pdat;
      struct dma_pl330_dmac *pdmac;
-     struct dma_pl330_chan *pch;
+     struct dma_pl330_chan *pch, *_p;
      struct pl330_info *pi;
      struct dma_device *pd;
      struct resource *res;
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
      ret = dma_async_device_register(pd);
      if (ret) {
              dev_err(&adev->dev, "unable to register DMAC\n");

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 2995

Quoted 10 lines
drivers/dma/pl330.c +9 -1
-             goto probe_err2;
+             goto probe_err3;
+     }
+
+     if (adev->dev.of_node) {
+             ret = of_dma_controller_register(adev->dev.of_node,
+                                      of_dma_pl330_xlate, pdmac);
+             if (ret) {
+                     dev_err(&adev->dev,
+                     "unable to register DMA to the generic DT DMA helpers\n");

Indent?

Okey.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/dma/pl330.c +3 -8
+             }
      }
 
      dev_info(&adev->dev,
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
              pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
              pi->pcfg.num_peri, pi->pcfg.num_events);
 
-     ret = of_dma_controller_register(adev->dev.of_node,
-                                      of_dma_pl330_xlate, pdmac);
-     if (ret) {
-             dev_err(&adev->dev,
-             "unable to register DMA to the generic DT DMA helpers\n");
-             goto probe_err2;
-     }
-
      return 0;
+probe_err3:
+     amba_set_drvdata(adev, NULL);
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/dma/pl330.c pl330_probe(struct amba_device *adev, const struct amba_id *id) · line 3020

Quoted 10 lines
drivers/dma/pl330.c +10 -0
+     /* Idle the DMAC */
+     list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
+                     chan.device_node) {
+
+             /* Remove the channel */
+             list_del(&pch->chan.device_node);
+
+             /* Flush the channel */
+             pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
+             pl330_free_chan_resources(&pch->chan);

free_chan for error handling in probe?

Will remove this.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/dma/pl330.c +4 -2
+     }
 probe_err2:
      pl330_del(pi);
 probe_err1:
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev)
      if (!pdmac)
              return 0;
 
-     of_dma_controller_free(adev->dev.of_node);
+     if (adev->dev.of_node)
+             of_dma_controller_free(adev->dev.of_node);
 
+     dma_async_device_unregister(&pdmac->ddma);
      amba_set_drvdata(adev, NULL);
 
      /* Idle the DMAC */
--

1.7.4.4

#7 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

In reply to Padmavathi Venna
Quoted 5 lines · Padmavathi Venna

This patch returns error when 'dma-cells' property not found in the corresponding device node. With out this change there is a crash in the generic dma incompatible platforms.

NAK.

#dma-cells should be optional. It is not needed for platforms supporting memory to memory transfers only and should therefore be optional. You cannot assume the dtb can be updated and kernel changes need to work with old dtbs. I've submitted patches to address this and fix the crash:

https://lists.ozlabs.org/pipermail/devicetree-discuss/2013-February/028769.html

Rob

Quoted 34 lines

---

Based on Vinod Koul next branch.

 drivers/dma/of-dma.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/dma/of-dma.c +7 -1
index 69d04d2..46aca0d 100644
@@ -92,6 +92,7 @@ int of_dma_controller_register(struct device_node *np,
 				void *data)
 {
 	struct of_dma	*ofdma;
+	const	 __be32 *ip;
 	int		nbcells;
 
 	if (!np || !of_dma_xlate) {
@@ -103,7 +104,12 @@ int of_dma_controller_register(struct device_node *np,
 	if (!ofdma)
 		return -ENOMEM;
 
-	nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
+	ip = of_get_property(np, "#dma-cells", NULL);
+	if (!ip)
+		return -ENXIO;
+
+	nbcells = be32_to_cpup(ip);
+
 	if (!nbcells) {
 		pr_err("%s: #dma-cells property is missing or invalid\n",
 		       __func__);
#8 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

Quoted 7 lines · Rob Herring
Quoted 5 lines · Padmavathi Venna

This patch returns error when 'dma-cells' property not found in the corresponding device node. With out this change there is a crash in the generic dma incompatible platforms.

Quoted 9 lines

NAK.

#dma-cells should be optional. It is not needed for platforms supporting memory to memory transfers only and should therefore be optional. You cannot assume the dtb can be updated and kernel changes need to work with old dtbs. I've submitted patches to address this and fix the crash:

https://lists.ozlabs.org/pipermail/devicetree-discuss/2013-February/028769.html

Okay.

Thanks
Padma

Quoted 36 lines

Rob

Quoted 34 lines

---

Based on Vinod Koul next branch.

 drivers/dma/of-dma.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/dma/of-dma.c +7 -1
index 69d04d2..46aca0d 100644
@@ -92,6 +92,7 @@ int of_dma_controller_register(struct device_node *np,
                              void *data)
 {
      struct of_dma   *ofdma;
+     const    __be32 *ip;
      int             nbcells;
 
      if (!np || !of_dma_xlate) {
@@ -103,7 +104,12 @@ int of_dma_controller_register(struct device_node *np,
      if (!ofdma)
              return -ENOMEM;
 
-     nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
+     ip = of_get_property(np, "#dma-cells", NULL);
+     if (!ip)
+             return -ENXIO;
+
+     nbcells = be32_to_cpup(ip);
+
      if (!nbcells) {
              pr_err("%s: #dma-cells property is missing or invalid\n",
                     __func__);
#9 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

In reply to Rob Herring
Quoted 7 lines · On Tuesday 05 March 2013 03:43:52 Rob Herring wrote:
Quoted 5 lines · Padmavathi Venna

This patch returns error when 'dma-cells' property not found in the corresponding device node. With out this change there is a crash in the generic dma incompatible platforms.

Quoted 8 lines

NAK.

#dma-cells should be optional. It is not needed for platforms supporting memory to memory transfers only and should therefore be optional. You cannot assume the dtb can be updated and kernel changes need to work with old dtbs. I've submitted patches to address this and fix the crash:

https://lists.ozlabs.org/pipermail/devicetree-discuss/2013-February/028769.html

Why would you call of_dma_controller_register() for a dma engine that does not support slave channels, when that is the only purpose of that interface?

Note that the binding defines #dma-cells as required, and it does not make any sense otherwise.

Arnd

#10 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

Quoted 15 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 05 March 2013 03:43:52 Rob Herring wrote:
Quoted 5 lines · Padmavathi Venna

This patch returns error when 'dma-cells' property not found in the corresponding device node. With out this change there is a crash in the generic dma incompatible platforms.

NAK.

#dma-cells should be optional. It is not needed for platforms supporting memory to memory transfers only and should therefore be optional. You cannot assume the dtb can be updated and kernel changes need to work with old dtbs. I've submitted patches to address this and fix the crash:

Quoted 5 lines
Quoted 1 line

https://lists.ozlabs.org/pipermail/devicetree-discuss/2013-February/028769.html

Why would you call of_dma_controller_register() for a dma engine that does not support slave channels, when that is the only purpose of that interface?

Well maybe then that function should be allowed to fail without erroring out. I just fixed it a the line that failed. Doing be32_to_cpup directly on a function return that can be NULL is not correct either.

Quoted 2 lines

Note that the binding defines #dma-cells as required, and it does not make any sense otherwise.

The 2nd patch I submitted changes that. It does not make sense to require it if you have no requests and hence will never have a phandle reference in a slave device. The simple fact is that the pl330 had an existing binding that worked for the memory to memory only case and kernel changes broke this. Kernel changes should not break existing device-trees.

Rob

#11 lore raw

PATCH 1/1 dma: of-dma: return error when 'dma-cells' not found

Quoted 6 lines · Rob Herring
Quoted 3 lines

Why would you call of_dma_controller_register() for a dma engine that does not support slave channels, when that is the only purpose of that interface?

Well maybe then that function should be allowed to fail without erroring out. I just fixed it a the line that failed.

We have a lot of interfaces that fall back to silently doing nothing when there is no need.

Quoted 2 lines

Doing be32_to_cpup directly
on a function return that can be NULL is not correct either.

Agreed.

Quoted 6 lines
Quoted 2 lines

Note that the binding defines #dma-cells as required, and it does not make any sense otherwise.

The 2nd patch I submitted changes that. It does not make sense to require it if you have no requests and hence will never have a phandle reference in a slave device.

I still don't see why you would want to use the binding for dma slaves to describe a dmaengine that does not have slaves.

Quoted 4 lines

The simple fact is that the pl330 had an
existing binding that worked for the memory to memory only case and kernel changes broke this. Kernel changes should not break existing device-trees.

Of course we should not break the existing device tree, but I think it would be more sensible to change the pl330 specific binding in this case to require the use of the generic dma slave binding only when there are slaves connected to it.

If the #dma-cells property is absent, the pl330 driver can be changed not to call of_dma_controller_register.

Arnd