Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support
@ 2019-09-04  8:24 Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 1/3] dmaengine: rcar-dmac: Use of_data values instead of a macro Yoshihiro Shimoda
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-04  8:24 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch series is based on the latest slave-dma.git / next branch and
merge the latest slave-dma.git / fixes branch. This is because this patch
series depends on the following commit:
---
commit cf24aac38698bfa1d021afd3883df3c4c65143a4
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Mon Sep 2 20:44:03 2019 +0900

    dmaengine: rcar-dmac: Fix DMACHCLR handling if iommu is mapped
---

Changes from v1:
 - Combine two patch series into this patch series.
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
 - Remove a patch because updated patch is already merged into
   the latest slave-dma.git / fixes branch as described above.
 - Add Reviewed-by tags into all patches.
 - Rename a member of rcar_dmac_of_data.
 - Just ignore the return value of of_property_read_u32() for dma-channel-mask.

Yoshihiro Shimoda (3):
  dmaengine: rcar-dmac: Use of_data values instead of a macro
  dmaengine: rcar-dmac: Use devm_platform_ioremap_resource()
  dmaengine: rcar-dmac: Add dma-channel-mask property support

 drivers/dma/sh/rcar-dmac.c | 47 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 9 deletions(-)

-- 
2.7.4


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

* [PATCH v2 1/3] dmaengine: rcar-dmac: Use of_data values instead of a macro
  2019-09-04  8:24 [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Yoshihiro Shimoda
@ 2019-09-04  8:24 ` Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 2/3] dmaengine: rcar-dmac: Use devm_platform_ioremap_resource() Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-04  8:24 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

Since we will have changed memory mapping of the DMAC in the future,
this patch uses of_data values instead of a macro to calculate
each channel's base offset.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/dma/sh/rcar-dmac.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 3993ab6..74996a0 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -210,12 +210,20 @@ struct rcar_dmac {
 
 #define to_rcar_dmac(d)		container_of(d, struct rcar_dmac, engine)
 
+/*
+ * struct rcar_dmac_of_data - This driver's OF data
+ * @chan_offset_base: DMAC channels base offset
+ * @chan_offset_stride: DMAC channels offset stride
+ */
+struct rcar_dmac_of_data {
+	u32 chan_offset_base;
+	u32 chan_offset_stride;
+};
+
 /* -----------------------------------------------------------------------------
  * Registers
  */
 
-#define RCAR_DMAC_CHAN_OFFSET(i)	(0x8000 + 0x80 * (i))
-
 #define RCAR_DMAISTA			0x0020
 #define RCAR_DMASEC			0x0030
 #define RCAR_DMAOR			0x0060
@@ -1726,6 +1734,7 @@ static const struct dev_pm_ops rcar_dmac_pm = {
 
 static int rcar_dmac_chan_probe(struct rcar_dmac *dmac,
 				struct rcar_dmac_chan *rchan,
+				const struct rcar_dmac_of_data *data,
 				unsigned int index)
 {
 	struct platform_device *pdev = to_platform_device(dmac->dev);
@@ -1735,7 +1744,8 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac,
 	int ret;
 
 	rchan->index = index;
-	rchan->iomem = dmac->iomem + RCAR_DMAC_CHAN_OFFSET(index);
+	rchan->iomem = dmac->iomem + data->chan_offset_base +
+		       data->chan_offset_stride * index;
 	rchan->mid_rid = -EINVAL;
 
 	spin_lock_init(&rchan->lock);
@@ -1813,10 +1823,15 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 		DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES;
 	struct dma_device *engine;
 	struct rcar_dmac *dmac;
+	const struct rcar_dmac_of_data *data;
 	struct resource *mem;
 	unsigned int i;
 	int ret;
 
+	data = of_device_get_match_data(&pdev->dev);
+	if (!data)
+		return -EINVAL;
+
 	dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL);
 	if (!dmac)
 		return -ENOMEM;
@@ -1901,7 +1916,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 		if (!(dmac->channels_mask & BIT(i)))
 			continue;
 
-		ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], i);
+		ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], data, i);
 		if (ret < 0)
 			goto error;
 	}
@@ -1948,8 +1963,16 @@ static void rcar_dmac_shutdown(struct platform_device *pdev)
 	rcar_dmac_stop_all_chan(dmac);
 }
 
+static const struct rcar_dmac_of_data rcar_dmac_data = {
+	.chan_offset_base = 0x8000,
+	.chan_offset_stride = 0x80,
+};
+
 static const struct of_device_id rcar_dmac_of_ids[] = {
-	{ .compatible = "renesas,rcar-dmac", },
+	{
+		.compatible = "renesas,rcar-dmac",
+		.data = &rcar_dmac_data,
+	},
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, rcar_dmac_of_ids);
-- 
2.7.4


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

* [PATCH v2 2/3] dmaengine: rcar-dmac: Use devm_platform_ioremap_resource()
  2019-09-04  8:24 [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 1/3] dmaengine: rcar-dmac: Use of_data values instead of a macro Yoshihiro Shimoda
@ 2019-09-04  8:24 ` Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 3/3] dmaengine: rcar-dmac: Add dma-channel-mask property support Yoshihiro Shimoda
  2019-09-04  9:36 ` [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Vinod Koul
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-04  8:24 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch uses devm_platform_ioremap_resource() instead of
using platform_get_resource() and devm_ioremap_resource() together
to simplify.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/dma/sh/rcar-dmac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 74996a0..542786d 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1824,7 +1824,6 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 	struct dma_device *engine;
 	struct rcar_dmac *dmac;
 	const struct rcar_dmac_of_data *data;
-	struct resource *mem;
 	unsigned int i;
 	int ret;
 
@@ -1863,8 +1862,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* Request resources. */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dmac->iomem = devm_ioremap_resource(&pdev->dev, mem);
+	dmac->iomem = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(dmac->iomem))
 		return PTR_ERR(dmac->iomem);
 
-- 
2.7.4


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

* [PATCH v2 3/3] dmaengine: rcar-dmac: Add dma-channel-mask property support
  2019-09-04  8:24 [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 1/3] dmaengine: rcar-dmac: Use of_data values instead of a macro Yoshihiro Shimoda
  2019-09-04  8:24 ` [PATCH v2 2/3] dmaengine: rcar-dmac: Use devm_platform_ioremap_resource() Yoshihiro Shimoda
@ 2019-09-04  8:24 ` Yoshihiro Shimoda
  2019-09-04  9:36 ` [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Vinod Koul
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-04  8:24 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch adds dma-channel-mask property support not to reserve
some DMA channels for some reasons. (for example: a heterogeneous
CPU uses it.)

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/dma/sh/rcar-dmac.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 542786d..f06016d 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -203,7 +203,7 @@ struct rcar_dmac {
 
 	unsigned int n_channels;
 	struct rcar_dmac_chan *channels;
-	unsigned int channels_mask;
+	u32 channels_mask;
 
 	DECLARE_BITMAP(modules, 256);
 };
@@ -1810,7 +1810,15 @@ static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)
 		return -EINVAL;
 	}
 
+	/*
+	 * If the driver is unable to read dma-channel-mask property,
+	 * the driver assumes that it can use all channels.
+	 */
 	dmac->channels_mask = GENMASK(dmac->n_channels - 1, 0);
+	of_property_read_u32(np, "dma-channel-mask", &dmac->channels_mask);
+
+	/* If the property has out-of-channel mask, this driver clears it */
+	dmac->channels_mask &= GENMASK(dmac->n_channels - 1, 0);
 
 	return 0;
 }
-- 
2.7.4


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

* Re: [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support
  2019-09-04  8:24 [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2019-09-04  8:24 ` [PATCH v2 3/3] dmaengine: rcar-dmac: Add dma-channel-mask property support Yoshihiro Shimoda
@ 2019-09-04  9:36 ` Vinod Koul
  2019-09-04 10:08   ` Yoshihiro Shimoda
  3 siblings, 1 reply; 6+ messages in thread
From: Vinod Koul @ 2019-09-04  9:36 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: dmaengine, linux-renesas-soc

On 04-09-19, 17:24, Yoshihiro Shimoda wrote:
> This patch series is based on the latest slave-dma.git / next branch and
> merge the latest slave-dma.git / fixes branch. This is because this patch
> series depends on the following commit:

Well it should not depend on fix which is going for 5.3 and the rest for
5.4

Can you please rebase on next and send. This doesnt apply for me

Thanks

> ---
> commit cf24aac38698bfa1d021afd3883df3c4c65143a4
> Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Date:   Mon Sep 2 20:44:03 2019 +0900
> 
>     dmaengine: rcar-dmac: Fix DMACHCLR handling if iommu is mapped
> ---
> 
> Changes from v1:
>  - Combine two patch series into this patch series.
> https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
> https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
>  - Remove a patch because updated patch is already merged into
>    the latest slave-dma.git / fixes branch as described above.
>  - Add Reviewed-by tags into all patches.
>  - Rename a member of rcar_dmac_of_data.
>  - Just ignore the return value of of_property_read_u32() for dma-channel-mask.
> 
> Yoshihiro Shimoda (3):
>   dmaengine: rcar-dmac: Use of_data values instead of a macro
>   dmaengine: rcar-dmac: Use devm_platform_ioremap_resource()
>   dmaengine: rcar-dmac: Add dma-channel-mask property support
> 
>  drivers/dma/sh/rcar-dmac.c | 47 +++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 38 insertions(+), 9 deletions(-)
> 
> -- 
> 2.7.4

-- 
~Vinod

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

* RE: [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support
  2019-09-04  9:36 ` [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Vinod Koul
@ 2019-09-04 10:08   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-04 10:08 UTC (permalink / raw)
  To: Vinod Koul; +Cc: dmaengine, linux-renesas-soc

Hi Vinod,

> From: Vinod Koul, Sent: Wednesday, September 4, 2019 6:36 PM
> 
> On 04-09-19, 17:24, Yoshihiro Shimoda wrote:
> > This patch series is based on the latest slave-dma.git / next branch and
> > merge the latest slave-dma.git / fixes branch. This is because this patch
> > series depends on the following commit:
> 
> Well it should not depend on fix which is going for 5.3 and the rest for
> 5.4
> 
> Can you please rebase on next and send. This doesnt apply for me

I'm sorry for bothering you. I have a question. The patch 1/3 [1] and 3/3 [2]
completely depends on the fix patch [3] because the fix patch added
a new member and the patch 3/3 used it. How do I handle such a case?
Should I wait for submitting this patch series until v5.3 is released?
# If so, I think this means this patch series will be merged into v5.5.

[1] https://patchwork.kernel.org/patch/11129607/
[2] https://patchwork.kernel.org/patch/11129601/
[3]
https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/slave-dma.git/commit/?h=fixes&id=cf24aac38698bfa1d021afd3883df3c4c65143a4

Best regards,
Yoshihiro Shimoda

> Thanks
> 
> > ---
> > commit cf24aac38698bfa1d021afd3883df3c4c65143a4
> > Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > Date:   Mon Sep 2 20:44:03 2019 +0900
> >
> >     dmaengine: rcar-dmac: Fix DMACHCLR handling if iommu is mapped
> > ---
> >
> > Changes from v1:
> >  - Combine two patch series into this patch series.
> > https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
> > https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=166457&state=*
> >  - Remove a patch because updated patch is already merged into
> >    the latest slave-dma.git / fixes branch as described above.
> >  - Add Reviewed-by tags into all patches.
> >  - Rename a member of rcar_dmac_of_data.
> >  - Just ignore the return value of of_property_read_u32() for dma-channel-mask.
> >
> > Yoshihiro Shimoda (3):
> >   dmaengine: rcar-dmac: Use of_data values instead of a macro
> >   dmaengine: rcar-dmac: Use devm_platform_ioremap_resource()
> >   dmaengine: rcar-dmac: Add dma-channel-mask property support
> >
> >  drivers/dma/sh/rcar-dmac.c | 47 +++++++++++++++++++++++++++++++++++++---------
> >  1 file changed, 38 insertions(+), 9 deletions(-)
> >
> > --
> > 2.7.4
> 
> --
> ~Vinod

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  8:24 [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Yoshihiro Shimoda
2019-09-04  8:24 ` [PATCH v2 1/3] dmaengine: rcar-dmac: Use of_data values instead of a macro Yoshihiro Shimoda
2019-09-04  8:24 ` [PATCH v2 2/3] dmaengine: rcar-dmac: Use devm_platform_ioremap_resource() Yoshihiro Shimoda
2019-09-04  8:24 ` [PATCH v2 3/3] dmaengine: rcar-dmac: Add dma-channel-mask property support Yoshihiro Shimoda
2019-09-04  9:36 ` [PATCH v2 0/3] dmaengine: rcar-dmac: use of_data and add dma-channel-mask support Vinod Koul
2019-09-04 10:08   ` Yoshihiro Shimoda

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox