Re: [PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-09-14 Thread Guennadi Liakhovetski
Hi Sergei

On Sat, 14 Sep 2013, Sergei Shtylyov wrote:

> Hello.
> 
> On 09/14/2013 10:33 PM, Guennadi Liakhovetski wrote:
> 
> > > From: Max Filippov 
> 
> > > Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base'
> > > DMA
> > > driver framework.
> 
> > > Based on the original patch by Phil Edworthy .
> 
> > > Signed-off-by: Max Filippov 
> > > [Sergei: removed useless #include, sorted #include's, fixed
> > > HPB_DMA_TCR_MAX,
> > > fixed formats and removed line breaks in the dev_dbg() calls, rephrased
> > > and
> > > added IRQ # to the shdma_request_irq() failure message, added
> > > MODULE_AUTHOR(),
> > > removed '__init'/'__exit' annotations from the probe()/remove() methods,
> > > removed
> > > '__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in
> > > the
> > > header file, fixed #define ASYNCRSTR_ASRST20, added #define
> > > ASYNCRSTR_ASRST24,
> > > added the necessary runtime PM calls to the probe() and remove() methods,
> > > handled errors returned by dma_async_device_register(), beautified
> > > comments
> > > and #define's.]
> > > Signed-off-by: Sergei Shtylyov 
> 
> > > ---
> 
> > [snip]
> 
> > > Index: slave-dma/drivers/dma/sh/rcar-hpbdma.c
> > > ===
> > > --- /dev/null
> > > +++ slave-dma/drivers/dma/sh/rcar-hpbdma.c
> > > @@ -0,0 +1,655 @@
> 
> > [snip]
> 
> > > +static int hpb_dmae_chan_probe(struct hpb_dmae_device *hpbdev, int id)
> > > +{
> > > + struct shdma_dev *sdev = &hpbdev->shdma_dev;
> > > + struct platform_device *pdev =
> > > + to_platform_device(hpbdev->shdma_dev.dma_dev.dev);
> > > + struct hpb_dmae_chan *new_hpb_chan;
> > > + struct shdma_chan *schan;
> > > +
> > > + /* Alloc channel */
> > > + new_hpb_chan = devm_kzalloc(&pdev->dev,
> > > + sizeof(struct hpb_dmae_chan), GFP_KERNEL);
> > > + if (!new_hpb_chan) {
> > > + dev_err(hpbdev->shdma_dev.dma_dev.dev,
> > > + "No free memory for allocating DMA channels!\n");
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + schan = &new_hpb_chan->shdma_chan;
> 
> > A suggestion for an incremental patch - you might want to initialise the
> > max_xfer_len field like
> 
> > schan->max_xfer_len = 64 * 1024 * 1024 - 1;
> 
>IIRC, the HPB-DMAC's maximum transfer length is 16 MiB, without -1. You
> probably mixed it with LBSC-DMAC which is indeed capable of 64 MiB.

Sorry, no idea what the correct value for HPB DMAC is. This was just an 
example.

Thanks
Guennadi

> > because if it isn't initialised your max transfer length will be 4k,
> > which will hurt your performance. I think you should get a better
> > throughput after that
> 
>OK, note taken. We'll look into it.
> 
> WBR, Sergei

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-09-14 Thread Sergei Shtylyov

Hello.

On 09/14/2013 10:33 PM, Guennadi Liakhovetski wrote:


From: Max Filippov 



Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base' DMA
driver framework.



Based on the original patch by Phil Edworthy .



Signed-off-by: Max Filippov 
[Sergei: removed useless #include, sorted #include's, fixed HPB_DMA_TCR_MAX,
fixed formats and removed line breaks in the dev_dbg() calls, rephrased and
added IRQ # to the shdma_request_irq() failure message, added MODULE_AUTHOR(),
removed '__init'/'__exit' annotations from the probe()/remove() methods, removed
'__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in the
header file, fixed #define ASYNCRSTR_ASRST20, added #define ASYNCRSTR_ASRST24,
added the necessary runtime PM calls to the probe() and remove() methods,
handled errors returned by dma_async_device_register(), beautified comments
and #define's.]
Signed-off-by: Sergei Shtylyov 



---



[snip]



Index: slave-dma/drivers/dma/sh/rcar-hpbdma.c
===
--- /dev/null
+++ slave-dma/drivers/dma/sh/rcar-hpbdma.c
@@ -0,0 +1,655 @@



[snip]



+static int hpb_dmae_chan_probe(struct hpb_dmae_device *hpbdev, int id)
+{
+   struct shdma_dev *sdev = &hpbdev->shdma_dev;
+   struct platform_device *pdev =
+   to_platform_device(hpbdev->shdma_dev.dma_dev.dev);
+   struct hpb_dmae_chan *new_hpb_chan;
+   struct shdma_chan *schan;
+
+   /* Alloc channel */
+   new_hpb_chan = devm_kzalloc(&pdev->dev,
+   sizeof(struct hpb_dmae_chan), GFP_KERNEL);
+   if (!new_hpb_chan) {
+   dev_err(hpbdev->shdma_dev.dma_dev.dev,
+   "No free memory for allocating DMA channels!\n");
+   return -ENOMEM;
+   }
+
+   schan = &new_hpb_chan->shdma_chan;



A suggestion for an incremental patch - you might want to initialise the
max_xfer_len field like



schan->max_xfer_len = 64 * 1024 * 1024 - 1;


   IIRC, the HPB-DMAC's maximum transfer length is 16 MiB, without -1. You 
probably mixed it with LBSC-DMAC which is indeed capable of 64 MiB.



because if it isn't initialised your max transfer length will be 4k,
which will hurt your performance. I think you should get a better
throughput after that


   OK, note taken. We'll look into it.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-09-14 Thread Guennadi Liakhovetski
On Sun, 25 Aug 2013, Sergei Shtylyov wrote:

> From: Max Filippov 
> 
> Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base' DMA 
> driver framework.
> 
> Based on the original patch by Phil Edworthy .
> 
> Signed-off-by: Max Filippov 
> [Sergei: removed useless #include, sorted #include's, fixed HPB_DMA_TCR_MAX,
> fixed formats and removed line breaks in the dev_dbg() calls, rephrased and
> added IRQ # to the shdma_request_irq() failure message, added MODULE_AUTHOR(),
> removed '__init'/'__exit' annotations from the probe()/remove() methods, 
> removed
> '__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in the
> header file, fixed #define ASYNCRSTR_ASRST20, added #define ASYNCRSTR_ASRST24,
> added the necessary runtime PM calls to the probe() and remove() methods,
> handled errors returned by dma_async_device_register(), beautified comments
> and #define's.]
> Signed-off-by: Sergei Shtylyov 
> 
> ---

[snip]

> Index: slave-dma/drivers/dma/sh/rcar-hpbdma.c
> ===
> --- /dev/null
> +++ slave-dma/drivers/dma/sh/rcar-hpbdma.c
> @@ -0,0 +1,655 @@

[snip]

> +static int hpb_dmae_chan_probe(struct hpb_dmae_device *hpbdev, int id)
> +{
> + struct shdma_dev *sdev = &hpbdev->shdma_dev;
> + struct platform_device *pdev =
> + to_platform_device(hpbdev->shdma_dev.dma_dev.dev);
> + struct hpb_dmae_chan *new_hpb_chan;
> + struct shdma_chan *schan;
> +
> + /* Alloc channel */
> + new_hpb_chan = devm_kzalloc(&pdev->dev,
> + sizeof(struct hpb_dmae_chan), GFP_KERNEL);
> + if (!new_hpb_chan) {
> + dev_err(hpbdev->shdma_dev.dma_dev.dev,
> + "No free memory for allocating DMA channels!\n");
> + return -ENOMEM;
> + }
> +
> + schan = &new_hpb_chan->shdma_chan;

A suggestion for an incremental patch - you might want to initialise the
max_xfer_len field like

schan->max_xfer_len = 64 * 1024 * 1024 - 1;

because if it isn't initialised your max transfer length will be 4k,
which will hurt your performance. I think you should get a better
throughput after that

> + shdma_chan_probe(sdev, schan, id);
> +
> + if (pdev->id >= 0)
> + snprintf(new_hpb_chan->dev_id, sizeof(new_hpb_chan->dev_id),
> +  "hpb-dmae%d.%d", pdev->id, id);
> + else
> + snprintf(new_hpb_chan->dev_id, sizeof(new_hpb_chan->dev_id),
> +  "hpb-dma.%d", id);
> +
> + return 0;
> +}

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-09-02 Thread Vinod Koul
On Sun, Aug 25, 2013 at 12:33:24AM +0400, Sergei Shtylyov wrote:
> From: Max Filippov 
> 
> Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base' DMA 
> driver framework.
> 
> Based on the original patch by Phil Edworthy .
> 
> Signed-off-by: Max Filippov 
> [Sergei: removed useless #include, sorted #include's, fixed HPB_DMA_TCR_MAX,
> fixed formats and removed line breaks in the dev_dbg() calls, rephrased and
> added IRQ # to the shdma_request_irq() failure message, added MODULE_AUTHOR(),
> removed '__init'/'__exit' annotations from the probe()/remove() methods, 
> removed
> '__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in the
> header file, fixed #define ASYNCRSTR_ASRST20, added #define ASYNCRSTR_ASRST24,
> added the necessary runtime PM calls to the probe() and remove() methods,
> handled errors returned by dma_async_device_register(), beautified comments
> and #define's.]
> Signed-off-by: Sergei Shtylyov 
Applied, thanks

~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-08-30 Thread Sergei Shtylyov

Hello.

On 08/25/2013 12:33 AM, Sergei Shtylyov wrote:


From: Max Filippov 



Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base' DMA
driver framework.



Based on the original patch by Phil Edworthy .



Signed-off-by: Max Filippov 
[Sergei: removed useless #include, sorted #include's, fixed HPB_DMA_TCR_MAX,
fixed formats and removed line breaks in the dev_dbg() calls, rephrased and
added IRQ # to the shdma_request_irq() failure message, added MODULE_AUTHOR(),
removed '__init'/'__exit' annotations from the probe()/remove() methods, removed
'__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in the
header file, fixed #define ASYNCRSTR_ASRST20, added #define ASYNCRSTR_ASRST24,
added the necessary runtime PM calls to the probe() and remove() methods,
handled errors returned by dma_async_device_register(), beautified comments
and #define's.]
Signed-off-by: Sergei Shtylyov 


   Vinod, we've posted the updated patch almost a week ago. Is there any hope 
to get it into 3.12?


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] dma: add driver for R-Car HPB-DMAC

2013-08-24 Thread Sergei Shtylyov
From: Max Filippov 

Add support for HPB-DMAC found in Renesas R-Car SoCs, using 'shdma-base' DMA 
driver framework.

Based on the original patch by Phil Edworthy .

Signed-off-by: Max Filippov 
[Sergei: removed useless #include, sorted #include's, fixed HPB_DMA_TCR_MAX,
fixed formats and removed line breaks in the dev_dbg() calls, rephrased and
added IRQ # to the shdma_request_irq() failure message, added MODULE_AUTHOR(),
removed '__init'/'__exit' annotations from the probe()/remove() methods, removed
'__initdata' annotation from 'hpb_dmae_driver', fixed guard macro name in the
header file, fixed #define ASYNCRSTR_ASRST20, added #define ASYNCRSTR_ASRST24,
added the necessary runtime PM calls to the probe() and remove() methods,
handled errors returned by dma_async_device_register(), beautified comments
and #define's.]
Signed-off-by: Sergei Shtylyov 

---
The patch is against the 'next' branch of Vinod Koul's 'slave-dma.git' repo. 

Changes in version 3:
- renamed all the register/bit #define's to include 'HBP_DMAE_' prefix; 
- switched from using __raw_{readl|writel}() to io{read|write}32() to add the
  barriers and fix register endianness to LE;
- added the necessary early return to set_slave() method;
- added the necessary runtime PM calls to the probe() and remove() methods;
- started handling errors returned by dma_async_device_register();
- removed '__exit' annotation from the remove() method;
- added the comment in desc_completed() method explaining why it's correct;
- beautified some commets.

Changes in version 2:
- removed '__init' annotation from the probe() method and removed '__initdata'
  annotation from 'hpb_dmae_driver';
- added the From: header to credit the real author.

 drivers/dma/sh/Kconfig|6 
 drivers/dma/sh/Makefile   |1 
 drivers/dma/sh/rcar-hpbdma.c  |  655 ++
 include/linux/platform_data/dma-rcar-hpbdma.h |  103 
 4 files changed, 765 insertions(+)

Index: slave-dma/drivers/dma/sh/Kconfig
===
--- slave-dma.orig/drivers/dma/sh/Kconfig
+++ slave-dma/drivers/dma/sh/Kconfig
@@ -22,3 +22,9 @@ config SUDMAC
depends on SH_DMAE_BASE
help
  Enable support for the Renesas SUDMAC controllers.
+
+config RCAR_HPB_DMAE
+   tristate "Renesas R-Car HPB DMAC support"
+   depends on SH_DMAE_BASE
+   help
+ Enable support for the Renesas R-Car series DMA controllers.
Index: slave-dma/drivers/dma/sh/Makefile
===
--- slave-dma.orig/drivers/dma/sh/Makefile
+++ slave-dma/drivers/dma/sh/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_SH_DMAE_BASE) += shdma-base.o shdma-of.o
 obj-$(CONFIG_SH_DMAE) += shdma.o
 obj-$(CONFIG_SUDMAC) += sudmac.o
+obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
Index: slave-dma/drivers/dma/sh/rcar-hpbdma.c
===
--- /dev/null
+++ slave-dma/drivers/dma/sh/rcar-hpbdma.c
@@ -0,0 +1,655 @@
+/*
+ * Copyright (C) 2011-2013 Renesas Electronics Corporation
+ * Copyright (C) 2013 Cogent Embedded, Inc.
+ *
+ * This file is based on the drivers/dma/sh/shdma.c
+ *
+ * Renesas SuperH DMA Engine support
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * - DMA of SuperH does not have Hardware DMA chain mode.
+ * - max DMA size is 16MB.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* DMA channel registers */
+#define HPB_DMAE_DSAR0 0x00
+#define HPB_DMAE_DDAR0 0x04
+#define HPB_DMAE_DTCR0 0x08
+#define HPB_DMAE_DSAR1 0x0C
+#define HPB_DMAE_DDAR1 0x10
+#define HPB_DMAE_DTCR1 0x14
+#define HPB_DMAE_DSASR 0x18
+#define HPB_DMAE_DDASR 0x1C
+#define HPB_DMAE_DTCSR 0x20
+#define HPB_DMAE_DPTR  0x24
+#define HPB_DMAE_DCR   0x28
+#define HPB_DMAE_DCMDR 0x2C
+#define HPB_DMAE_DSTPR 0x30
+#define HPB_DMAE_DSTSR 0x34
+#define HPB_DMAE_DDBGR 0x38
+#define HPB_DMAE_DDBGR20x3C
+#define HPB_DMAE_CHAN(n)   (0x40 * (n))
+
+/* DMA command register (DCMDR) bits */
+#define HPB_DMAE_DCMDR_BDOUT   BIT(7)
+#define HPB_DMAE_DCMDR_DQSPD   BIT(6)
+#define HPB_DMAE_DCMDR_DQSPC   BIT(5)
+#define HPB_DMAE_DCMDR_DMSPD   BIT(4)
+#define HPB_DMAE_DCMDR_DMSPC   BIT(3)
+#define HPB_DMAE_DCMDR_DQEND   BIT(2)
+#define HPB_DMAE_DCMDR_DNXTBIT(1)
+#define HPB_DMAE_DCMDR_DMENBIT(0)
+
+/* DMA forced stop register (DSTPR) bits */
+#define HPB_DMAE_DSTPR_DMSTP   BIT(0)
+
+/* DMA status register (DSTSR) bits */
+#define HPB_DMAE_DSTSR_DMSTS   BIT(0)
+
+/* DMA common registers */
+#define HPB_DMAE_DTIMR 0x00
+#define HPB_DMAE_DINTSR0   0x0C
+#define HPB_DMAE_DINTSR1   0x10
+#define HPB_DMA