dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] *** altera-msgdma: make response port optional ***
@ 2021-06-17 19:51 Olivier Dautricourt
  2021-06-17 19:52 ` [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional Olivier Dautricourt
  2021-06-17 19:53 ` [PATCH 2/2] dmaengine: " Olivier Dautricourt
  0 siblings, 2 replies; 7+ messages in thread
From: Olivier Dautricourt @ 2021-06-17 19:51 UTC (permalink / raw)
  To: Rob Herring, Vinod Koul, Stefan Roese
  Cc: Olivier Dautricourt, dmaengine, devicetree, linux-kernel

Response port can be disabled in the ip core configuration,
so allow not to specify one.

This patch serie is applicable on
git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git next

Olivier Dautricourt (2):
  dt-bindings: dma: altera-msgdma: make response port optional
  dmaengine: altera-msgdma: make response port optional

 .../devicetree/bindings/dma/altr,msgdma.yaml  |  4 +-
 drivers/dma/altera-msgdma.c                   | 37 +++++++++++++------
 2 files changed, 29 insertions(+), 12 deletions(-)


base-commit: 656758425f98693bd61a08f6b51c4c5aa26c9d50
--
2.31.0.rc2


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

* [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional
  2021-06-17 19:51 [PATCH 0/2] *** altera-msgdma: make response port optional *** Olivier Dautricourt
@ 2021-06-17 19:52 ` Olivier Dautricourt
  2021-06-18  5:54   ` Stefan Roese
  2021-06-24 21:34   ` Rob Herring
  2021-06-17 19:53 ` [PATCH 2/2] dmaengine: " Olivier Dautricourt
  1 sibling, 2 replies; 7+ messages in thread
From: Olivier Dautricourt @ 2021-06-17 19:52 UTC (permalink / raw)
  To: Rob Herring, Vinod Koul, Stefan Roese
  Cc: Olivier Dautricourt, dmaengine, devicetree, linux-kernel

Response port is not required in some configuration of the IP core.

Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>
---
 Documentation/devicetree/bindings/dma/altr,msgdma.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/dma/altr,msgdma.yaml b/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
index a4f9fe23dcd9..b193ee2db4a7 100644
--- a/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
+++ b/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
@@ -24,13 +24,15 @@ properties:
     items:
       - description: Control and Status Register Slave Port
       - description: Descriptor Slave Port
-      - description: Response Slave Port
+      - description: Response Slave Port (Optional)
+    minItems: 2

   reg-names:
     items:
       - const: csr
       - const: desc
       - const: resp
+    minItems: 2

   interrupts:
     maxItems: 1
--
2.31.0.rc2


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

* [PATCH 2/2] dmaengine: altera-msgdma: make response port optional
  2021-06-17 19:51 [PATCH 0/2] *** altera-msgdma: make response port optional *** Olivier Dautricourt
  2021-06-17 19:52 ` [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional Olivier Dautricourt
@ 2021-06-17 19:53 ` Olivier Dautricourt
  2021-06-18  5:54   ` Stefan Roese
  2021-07-28  6:54   ` Vinod Koul
  1 sibling, 2 replies; 7+ messages in thread
From: Olivier Dautricourt @ 2021-06-17 19:53 UTC (permalink / raw)
  To: Rob Herring, Vinod Koul, Stefan Roese
  Cc: Olivier Dautricourt, dmaengine, devicetree, linux-kernel

The response slave port can be disabled in some configuration [1] and
csr + MSGDMA_CSR_RESP_FILL_LEVEL will be 0 even if transfer has suceeded.
We have to only rely on the interrupts in that scenario.
This was tested on cyclone V with the controller resp port disabled.

[1] https://www.intel.com/content/www/us/en/programmable/documentation/sfo1400787952932.html
30.3.1.2
30.3.1.3
30.5.5

Fixes:
https://forum.rocketboards.org/t/ip-msgdma-linux-driver/1919
Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>
---
 drivers/dma/altera-msgdma.c | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 0fe0676f8e1d..5a2c7573b692 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -691,10 +691,14 @@ static void msgdma_tasklet(struct tasklet_struct *t)

 	spin_lock_irqsave(&mdev->lock, flags);

-	/* Read number of responses that are available */
-	count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL);
-	dev_dbg(mdev->dev, "%s (%d): response count=%d\n",
-		__func__, __LINE__, count);
+	if (mdev->resp) {
+		/* Read number of responses that are available */
+		count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL);
+		dev_dbg(mdev->dev, "%s (%d): response count=%d\n",
+			__func__, __LINE__, count);
+	} else {
+		count = 1;
+	}

 	while (count--) {
 		/*
@@ -703,8 +707,12 @@ static void msgdma_tasklet(struct tasklet_struct *t)
 		 * have any real values, like transferred bytes or error
 		 * bits. So we need to just drop these values.
 		 */
-		size = ioread32(mdev->resp + MSGDMA_RESP_BYTES_TRANSFERRED);
-		status = ioread32(mdev->resp + MSGDMA_RESP_STATUS);
+		if (mdev->resp) {
+			size = ioread32(mdev->resp +
+					MSGDMA_RESP_BYTES_TRANSFERRED);
+			status = ioread32(mdev->resp +
+					MSGDMA_RESP_STATUS);
+		}

 		msgdma_complete_descriptor(mdev);
 		msgdma_chan_desc_cleanup(mdev);
@@ -757,14 +765,21 @@ static void msgdma_dev_remove(struct msgdma_device *mdev)
 }

 static int request_and_map(struct platform_device *pdev, const char *name,
-			   struct resource **res, void __iomem **ptr)
+			   struct resource **res, void __iomem **ptr,
+			   bool optional)
 {
 	struct resource *region;
 	struct device *device = &pdev->dev;

 	*res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
 	if (*res == NULL) {
-		dev_err(device, "resource %s not defined\n", name);
+		if (optional) {
+			*ptr = NULL;
+			dev_info(device, "optional resource %s not defined\n",
+				 name);
+			return 0;
+		}
+		dev_err(device, "mandatory resource %s not defined\n", name);
 		return -ENODEV;
 	}

@@ -805,17 +820,17 @@ static int msgdma_probe(struct platform_device *pdev)
 	mdev->dev = &pdev->dev;

 	/* Map CSR space */
-	ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr);
+	ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr, false);
 	if (ret)
 		return ret;

 	/* Map (extended) descriptor space */
-	ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc);
+	ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc, false);
 	if (ret)
 		return ret;

 	/* Map response space */
-	ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp);
+	ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp, true);
 	if (ret)
 		return ret;

--
2.31.0.rc2


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

* Re: [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional
  2021-06-17 19:52 ` [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional Olivier Dautricourt
@ 2021-06-18  5:54   ` Stefan Roese
  2021-06-24 21:34   ` Rob Herring
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2021-06-18  5:54 UTC (permalink / raw)
  To: Olivier Dautricourt, Rob Herring, Vinod Koul
  Cc: dmaengine, devicetree, linux-kernel

On 17.06.21 21:52, Olivier Dautricourt wrote:
> Response port is not required in some configuration of the IP core.
> 
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   Documentation/devicetree/bindings/dma/altr,msgdma.yaml | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/dma/altr,msgdma.yaml b/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
> index a4f9fe23dcd9..b193ee2db4a7 100644
> --- a/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
> +++ b/Documentation/devicetree/bindings/dma/altr,msgdma.yaml
> @@ -24,13 +24,15 @@ properties:
>       items:
>         - description: Control and Status Register Slave Port
>         - description: Descriptor Slave Port
> -      - description: Response Slave Port
> +      - description: Response Slave Port (Optional)
> +    minItems: 2
> 
>     reg-names:
>       items:
>         - const: csr
>         - const: desc
>         - const: resp
> +    minItems: 2
> 
>     interrupts:
>       maxItems: 1
> --
> 2.31.0.rc2
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH 2/2] dmaengine: altera-msgdma: make response port optional
  2021-06-17 19:53 ` [PATCH 2/2] dmaengine: " Olivier Dautricourt
@ 2021-06-18  5:54   ` Stefan Roese
  2021-07-28  6:54   ` Vinod Koul
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2021-06-18  5:54 UTC (permalink / raw)
  To: Olivier Dautricourt, Rob Herring, Vinod Koul
  Cc: dmaengine, devicetree, linux-kernel

On 17.06.21 21:53, Olivier Dautricourt wrote:
> The response slave port can be disabled in some configuration [1] and
> csr + MSGDMA_CSR_RESP_FILL_LEVEL will be 0 even if transfer has suceeded.
> We have to only rely on the interrupts in that scenario.
> This was tested on cyclone V with the controller resp port disabled.
> 
> [1] https://www.intel.com/content/www/us/en/programmable/documentation/sfo1400787952932.html
> 30.3.1.2
> 30.3.1.3
> 30.5.5
> 
> Fixes:
> https://forum.rocketboards.org/t/ip-msgdma-linux-driver/1919
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   drivers/dma/altera-msgdma.c | 37 ++++++++++++++++++++++++++-----------
>   1 file changed, 26 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
> index 0fe0676f8e1d..5a2c7573b692 100644
> --- a/drivers/dma/altera-msgdma.c
> +++ b/drivers/dma/altera-msgdma.c
> @@ -691,10 +691,14 @@ static void msgdma_tasklet(struct tasklet_struct *t)
> 
>   	spin_lock_irqsave(&mdev->lock, flags);
> 
> -	/* Read number of responses that are available */
> -	count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL);
> -	dev_dbg(mdev->dev, "%s (%d): response count=%d\n",
> -		__func__, __LINE__, count);
> +	if (mdev->resp) {
> +		/* Read number of responses that are available */
> +		count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL);
> +		dev_dbg(mdev->dev, "%s (%d): response count=%d\n",
> +			__func__, __LINE__, count);
> +	} else {
> +		count = 1;
> +	}
> 
>   	while (count--) {
>   		/*
> @@ -703,8 +707,12 @@ static void msgdma_tasklet(struct tasklet_struct *t)
>   		 * have any real values, like transferred bytes or error
>   		 * bits. So we need to just drop these values.
>   		 */
> -		size = ioread32(mdev->resp + MSGDMA_RESP_BYTES_TRANSFERRED);
> -		status = ioread32(mdev->resp + MSGDMA_RESP_STATUS);
> +		if (mdev->resp) {
> +			size = ioread32(mdev->resp +
> +					MSGDMA_RESP_BYTES_TRANSFERRED);
> +			status = ioread32(mdev->resp +
> +					MSGDMA_RESP_STATUS);
> +		}
> 
>   		msgdma_complete_descriptor(mdev);
>   		msgdma_chan_desc_cleanup(mdev);
> @@ -757,14 +765,21 @@ static void msgdma_dev_remove(struct msgdma_device *mdev)
>   }
> 
>   static int request_and_map(struct platform_device *pdev, const char *name,
> -			   struct resource **res, void __iomem **ptr)
> +			   struct resource **res, void __iomem **ptr,
> +			   bool optional)
>   {
>   	struct resource *region;
>   	struct device *device = &pdev->dev;
> 
>   	*res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
>   	if (*res == NULL) {
> -		dev_err(device, "resource %s not defined\n", name);
> +		if (optional) {
> +			*ptr = NULL;
> +			dev_info(device, "optional resource %s not defined\n",
> +				 name);
> +			return 0;
> +		}
> +		dev_err(device, "mandatory resource %s not defined\n", name);
>   		return -ENODEV;
>   	}
> 
> @@ -805,17 +820,17 @@ static int msgdma_probe(struct platform_device *pdev)
>   	mdev->dev = &pdev->dev;
> 
>   	/* Map CSR space */
> -	ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr);
> +	ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr, false);
>   	if (ret)
>   		return ret;
> 
>   	/* Map (extended) descriptor space */
> -	ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc);
> +	ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc, false);
>   	if (ret)
>   		return ret;
> 
>   	/* Map response space */
> -	ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp);
> +	ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp, true);
>   	if (ret)
>   		return ret;
> 
> --
> 2.31.0.rc2
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional
  2021-06-17 19:52 ` [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional Olivier Dautricourt
  2021-06-18  5:54   ` Stefan Roese
@ 2021-06-24 21:34   ` Rob Herring
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2021-06-24 21:34 UTC (permalink / raw)
  To: Olivier Dautricourt
  Cc: Stefan Roese, devicetree, linux-kernel, Vinod Koul, dmaengine,
	Rob Herring

On Thu, 17 Jun 2021 21:52:32 +0200, Olivier Dautricourt wrote:
> Response port is not required in some configuration of the IP core.
> 
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>
> ---
>  Documentation/devicetree/bindings/dma/altr,msgdma.yaml | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 2/2] dmaengine: altera-msgdma: make response port optional
  2021-06-17 19:53 ` [PATCH 2/2] dmaengine: " Olivier Dautricourt
  2021-06-18  5:54   ` Stefan Roese
@ 2021-07-28  6:54   ` Vinod Koul
  1 sibling, 0 replies; 7+ messages in thread
From: Vinod Koul @ 2021-07-28  6:54 UTC (permalink / raw)
  To: Olivier Dautricourt
  Cc: Rob Herring, Stefan Roese, dmaengine, devicetree, linux-kernel

On 17-06-21, 21:53, Olivier Dautricourt wrote:
> The response slave port can be disabled in some configuration [1] and
> csr + MSGDMA_CSR_RESP_FILL_LEVEL will be 0 even if transfer has suceeded.
> We have to only rely on the interrupts in that scenario.
> This was tested on cyclone V with the controller resp port disabled.
> 
> [1] https://www.intel.com/content/www/us/en/programmable/documentation/sfo1400787952932.html
> 30.3.1.2
> 30.3.1.3
> 30.5.5
> 
> Fixes:
> https://forum.rocketboards.org/t/ip-msgdma-linux-driver/1919

This should be single line, fixed it up while applying the series

-- 
~Vinod

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

end of thread, other threads:[~2021-07-28  6:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 19:51 [PATCH 0/2] *** altera-msgdma: make response port optional *** Olivier Dautricourt
2021-06-17 19:52 ` [PATCH 1/2] dt-bindings: dma: altera-msgdma: make response port optional Olivier Dautricourt
2021-06-18  5:54   ` Stefan Roese
2021-06-24 21:34   ` Rob Herring
2021-06-17 19:53 ` [PATCH 2/2] dmaengine: " Olivier Dautricourt
2021-06-18  5:54   ` Stefan Roese
2021-07-28  6:54   ` Vinod Koul

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