Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386370 > unrolled thread

[PATCH v6 0/4] Fixes / cleanups in dw_dmac (affects on few subsystems)

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2016-04-25 14:40 +0200
Last post2016-04-27 08:50 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v6 0/4] Fixes / cleanups in dw_dmac (affects on few subsystems) Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-25 14:40 +0200
    [PATCH v6 4/4] dmaengine: dw: pass platform data via struct dw_dma_chip Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-25 14:40 +0200
      Re: [PATCH v6 4/4] dmaengine: dw: pass platform data via struct  dw_dma_chip Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-27 08:50 +0200
    [PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be non-zero Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-25 14:40 +0200
      Re: [PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be  non-zero Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-27 08:50 +0200

#1386370 — [PATCH v6 0/4] Fixes / cleanups in dw_dmac (affects on few subsystems)

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-04-25 14:40 +0200
Subject[PATCH v6 0/4] Fixes / cleanups in dw_dmac (affects on few subsystems)
Message-ID<rrNXY-5VY-13@gated-at.bofh.it>
This patch series (v3: http://www.spinics.net/lists/kernel/msg2215303.html)
contains a number of mostly minor fixes and cleanups for the DW DMA driver. A
couple of them affect the DT binding so these may need to be updated to
maintain compatibility (old format is still supported though). The rest should
be relatively straight-forward.

This version has been tested on the following bare metal platforms:
- ATNGW100 (avr32 based platform) with dmatest
- Sam460ex (powerpc 44x based platform) with SATA
- Intel Braswell with UART
- Intel Galileo (Intel Quark based platform) with UART

(SATA driver and Intel Galileo UART support are based on this series and just
 published recently for a review)

Vinod, there are few patch sets developed on top of this one, so, the idea is
to keep this in an immuutable branch / tag.

Changes since v5:
- fixed an issue found by kbuildbot

Changes since v4:
- send proper set of patches
- add changelog

Changes since v3:
- add patch 1 to check value of dma-masters property
- drop the upstreamed patches
- update patch 2 to keep an array for data-width property as well

Changes since v2:
- add patch 1 to fix master selection which was broken for long time
- remove "use field-by-field initialization" patch since like Mans metioned in
  has mostly no value and even might increase error prone
- rebase on top of recent linux-next
- wide testing on several platforms

Changes since v1:
- zeroing struct dw_dma_slave before use
- fall back to old data_width property if data-width is not found
- append tags for few patches
- correct title of cover letter
- rebase on top of recent linux-next

Andy Shevchenko (4):
  dmaengine: dw: platform: check nr_masters to be non-zero
  dmaengine: dw: revisit data_width property
  dmaengine: dw: keep entire platform data in struct dw_dma
  dmaengine: dw: pass platform data via struct dw_dma_chip

 Documentation/devicetree/bindings/dma/snps-dma.txt |  6 +-
 arch/arc/boot/dts/abilis_tb10x.dtsi                |  2 +-
 arch/arm/boot/dts/spear13xx.dtsi                   |  4 +-
 drivers/ata/sata_dwc_460ex.c                       |  2 +-
 drivers/dma/dw/core.c                              | 75 ++++++++--------------
 drivers/dma/dw/pci.c                               |  5 +-
 drivers/dma/dw/platform.c                          | 32 +++++----
 drivers/dma/dw/regs.h                              |  5 +-
 include/linux/dma/dw.h                             |  5 +-
 include/linux/platform_data/dma-dw.h               |  4 +-
 sound/soc/intel/common/sst-firmware.c              |  2 +-
 11 files changed, 64 insertions(+), 78 deletions(-)

-- 
2.8.0.rc3

[toc] | [next] | [standalone]


#1386377 — [PATCH v6 4/4] dmaengine: dw: pass platform data via struct dw_dma_chip

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-04-25 14:40 +0200
Subject[PATCH v6 4/4] dmaengine: dw: pass platform data via struct dw_dma_chip
Message-ID<rrNY0-5VY-53@gated-at.bofh.it>
In reply to#1386370
We pass struct dw_dma_chip to the dw_dma_probe() anyway, thus we may use it to
pass platform data as well.

While here, constify the source of platform data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/ata/sata_dwc_460ex.c          | 2 +-
 drivers/dma/dw/core.c                 | 9 +++++----
 drivers/dma/dw/pci.c                  | 5 +++--
 drivers/dma/dw/platform.c             | 5 +++--
 include/linux/dma/dw.h                | 5 ++++-
 sound/soc/intel/common/sst-firmware.c | 2 +-
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 80bdcab..2cb6f7e 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1248,7 +1248,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	hsdev->dma->dev = &ofdev->dev;
 
 	/* Initialize AHB DMAC */
-	err = dw_dma_probe(hsdev->dma, NULL);
+	err = dw_dma_probe(hsdev->dma);
 	if (err)
 		goto error_dma_iomap;
 
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 30843a1..edf053f 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -1439,8 +1439,9 @@ EXPORT_SYMBOL(dw_dma_cyclic_free);
 
 /*----------------------------------------------------------------------*/
 
-int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
+int dw_dma_probe(struct dw_dma_chip *chip)
 {
+	struct dw_dma_platform_data *pdata;
 	struct dw_dma		*dw;
 	bool			autocfg = false;
 	unsigned int		dw_params;
@@ -1460,7 +1461,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 
 	pm_runtime_get_sync(chip->dev);
 
-	if (!pdata) {
+	if (!chip->pdata) {
 		dw_params = dma_readl(dw, DW_PARAMS);
 		dev_dbg(chip->dev, "DW_PARAMS: 0x%08x\n", dw_params);
 
@@ -1487,11 +1488,11 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 		pdata->is_memcpy = true;
 		pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING;
 		pdata->chan_priority = CHAN_PRIORITY_ASCENDING;
-	} else if (pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) {
+	} else if (chip->pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) {
 		err = -EINVAL;
 		goto err_pdata;
 	} else {
-		memcpy(dw->pdata, pdata, sizeof(*dw->pdata));
+		memcpy(dw->pdata, chip->pdata, sizeof(*dw->pdata));
 
 		/* Reassign the platform data pointer */
 		pdata = dw->pdata;
diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
index 358f968..0ae6c3b 100644
--- a/drivers/dma/dw/pci.c
+++ b/drivers/dma/dw/pci.c
@@ -17,8 +17,8 @@
 
 static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
 {
+	const struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
 	struct dw_dma_chip *chip;
-	struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
 	int ret;
 
 	ret = pcim_enable_device(pdev);
@@ -49,8 +49,9 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
 	chip->dev = &pdev->dev;
 	chip->regs = pcim_iomap_table(pdev)[0];
 	chip->irq = pdev->irq;
+	chip->pdata = pdata;
 
-	ret = dw_dma_probe(chip, pdata);
+	ret = dw_dma_probe(chip);
 	if (ret)
 		return ret;
 
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 0a49011..5bda0eb 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -161,7 +161,7 @@ static int dw_probe(struct platform_device *pdev)
 	struct dw_dma_chip *chip;
 	struct device *dev = &pdev->dev;
 	struct resource *mem;
-	struct dw_dma_platform_data *pdata;
+	const struct dw_dma_platform_data *pdata;
 	int err;
 
 	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
@@ -186,6 +186,7 @@ static int dw_probe(struct platform_device *pdev)
 		pdata = dw_dma_parse_dt(pdev);
 
 	chip->dev = dev;
+	chip->pdata = pdata;
 
 	chip->clk = devm_clk_get(chip->dev, "hclk");
 	if (IS_ERR(chip->clk))
@@ -196,7 +197,7 @@ static int dw_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 
-	err = dw_dma_probe(chip, pdata);
+	err = dw_dma_probe(chip);
 	if (err)
 		goto err_dw_dma_probe;
 
diff --git a/include/linux/dma/dw.h b/include/linux/dma/dw.h
index 7145644..f2e538a 100644
--- a/include/linux/dma/dw.h
+++ b/include/linux/dma/dw.h
@@ -27,6 +27,7 @@ struct dw_dma;
  * @regs:		memory mapped I/O space
  * @clk:		hclk clock
  * @dw:			struct dw_dma that is filed by dw_dma_probe()
+ * @pdata:		pointer to platform data
  */
 struct dw_dma_chip {
 	struct device	*dev;
@@ -34,10 +35,12 @@ struct dw_dma_chip {
 	void __iomem	*regs;
 	struct clk	*clk;
 	struct dw_dma	*dw;
+
+	const struct dw_dma_platform_data	*pdata;
 };
 
 /* Export to the platform drivers */
-int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata);
+int dw_dma_probe(struct dw_dma_chip *chip);
 int dw_dma_remove(struct dw_dma_chip *chip);
 
 /* DMA API extensions */
diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index ef4881e..2599352 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -203,7 +203,7 @@ static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem,
 
 	chip->dev = dev;
 
-	err = dw_dma_probe(chip, NULL);
+	err = dw_dma_probe(chip);
 	if (err)
 		return ERR_PTR(err);
 
-- 
2.8.0.rc3

[toc] | [prev] | [next] | [standalone]


#1388700 — Re: [PATCH v6 4/4] dmaengine: dw: pass platform data via struct dw_dma_chip

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-27 08:50 +0200
SubjectRe: [PATCH v6 4/4] dmaengine: dw: pass platform data via struct dw_dma_chip
Message-ID<rsrsl-4Yn-5@gated-at.bofh.it>
In reply to#1386377
On 25-04-16, 15:35, Andy Shevchenko wrote:
> We pass struct dw_dma_chip to the dw_dma_probe() anyway, thus we may use it to
> pass platform data as well.
> 
> While here, constify the source of platform data.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/ata/sata_dwc_460ex.c          | 2 +-
>  drivers/dma/dw/core.c                 | 9 +++++----
>  drivers/dma/dw/pci.c                  | 5 +++--
>  drivers/dma/dw/platform.c             | 5 +++--
>  include/linux/dma/dw.h                | 5 ++++-
>  sound/soc/intel/common/sst-firmware.c | 2 +-
>  6 files changed, 17 insertions(+), 11 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

[toc] | [prev] | [next] | [standalone]


#1386378 — [PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be non-zero

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-04-25 14:40 +0200
Subject[PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be non-zero
Message-ID<rrNY0-5VY-51@gated-at.bofh.it>
In reply to#1386370
The nr_masters value equal to 0 is invalid since this DMA controller has to
have at least one master.

Check this before we proceed with the rest of properties.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/platform.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 23616c5..e65ebe5 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -103,6 +103,7 @@ dw_dma_parse_dt(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct dw_dma_platform_data *pdata;
 	u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
+	u32 nr_masters;
 	u32 nr_channels;
 
 	if (!np) {
@@ -110,6 +111,11 @@ dw_dma_parse_dt(struct platform_device *pdev)
 		return NULL;
 	}
 
+	if (of_property_read_u32(np, "dma-masters", &nr_masters))
+		return NULL;
+	if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS)
+		return NULL;
+
 	if (of_property_read_u32(np, "dma-channels", &nr_channels))
 		return NULL;
 
@@ -117,6 +123,7 @@ dw_dma_parse_dt(struct platform_device *pdev)
 	if (!pdata)
 		return NULL;
 
+	pdata->nr_masters = nr_masters;
 	pdata->nr_channels = nr_channels;
 
 	if (of_property_read_bool(np, "is_private"))
@@ -131,17 +138,10 @@ dw_dma_parse_dt(struct platform_device *pdev)
 	if (!of_property_read_u32(np, "block_size", &tmp))
 		pdata->block_size = tmp;
 
-	if (!of_property_read_u32(np, "dma-masters", &tmp)) {
-		if (tmp > DW_DMA_MAX_NR_MASTERS)
-			return NULL;
-
-		pdata->nr_masters = tmp;
-	}
-
-	if (!of_property_read_u32_array(np, "data_width", arr,
-				pdata->nr_masters))
-		for (tmp = 0; tmp < pdata->nr_masters; tmp++)
+	if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
+		for (tmp = 0; tmp < nr_masters; tmp++)
 			pdata->data_width[tmp] = arr[tmp];
+	}
 
 	return pdata;
 }
-- 
2.8.0.rc3

[toc] | [prev] | [next] | [standalone]


#1388699 — Re: [PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be non-zero

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-27 08:50 +0200
SubjectRe: [PATCH v6 1/4] dmaengine: dw: platform: check nr_masters to be non-zero
Message-ID<rsrsl-4Yn-3@gated-at.bofh.it>
In reply to#1386378
On 25-04-16, 15:35, Andy Shevchenko wrote:
> The nr_masters value equal to 0 is invalid since this DMA controller has to
> have at least one master.
> 
> Check this before we proceed with the rest of properties.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/dma/dw/platform.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web