dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
@ 2019-10-16 19:57 Daniel Vetter
  2019-10-16 21:30 ` Noralf Trønnes
  2019-10-17  6:44 ` Daniel Vetter
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-10-16 19:57 UTC (permalink / raw)
  To: DRI Development
  Cc: linux-arm-kernel, Andy Shevchenko, Daniel Vetter, Robert Jarzmik,
	Haojian Zhuang, linux-spi, Mark Brown, Sam Ravnborg, Daniel Mack

In DMA mode we have a maximum transfer size, past that the driver
falls back to PIO (see the check at the top of pxa2xx_spi_transfer_one).
Falling back to PIO for big transfers defeats the point of a dma engine,
hence set the max transfer size to inform spi clients that they need
to do something smarter.

This was uncovered by the drm_mipi_dbi spi panel code, which does
large spi transfers, but stopped splitting them after:

commit e143364b4c1774f68e923a5a0bb0fca28ac25888
Author: Noralf Trønnes <noralf@tronnes.org>
Date:   Fri Jul 19 17:59:10 2019 +0200

    drm/tinydrm: Remove tinydrm_spi_max_transfer_size()

After this commit the code relied on the spi core to split transfers
into max dma-able blocks, which also papered over the PIO fallback issue.

Fix this by setting the overall max transfer size to the DMA limit,
but only when the controller runs in DMA mode.

Fixes: e143364b4c17 ("drm/tinydrm: Remove tinydrm_spi_max_transfer_size()")
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Reported-and-tested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/spi/spi-pxa2xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index bb6a14d1ab0f..f77201915033 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1707,6 +1707,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
 		} else {
 			controller->can_dma = pxa2xx_spi_can_dma;
 			controller->max_dma_len = MAX_DMA_LEN;
+			controller->max_transfer_size = MAX_DMA_LEN;
 		}
 	}
 
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-16 19:57 [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode Daniel Vetter
@ 2019-10-16 21:30 ` Noralf Trønnes
  2019-10-16 21:49   ` Mark Brown
  2019-10-17  6:44 ` Daniel Vetter
  1 sibling, 1 reply; 7+ messages in thread
From: Noralf Trønnes @ 2019-10-16 21:30 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development
  Cc: Andy Shevchenko, Sam Ravnborg, Haojian Zhuang, linux-spi,
	Mark Brown, linux-arm-kernel, Robert Jarzmik, Daniel Mack



Den 16.10.2019 21.57, skrev Daniel Vetter:
> In DMA mode we have a maximum transfer size, past that the driver
> falls back to PIO (see the check at the top of pxa2xx_spi_transfer_one).
> Falling back to PIO for big transfers defeats the point of a dma engine,
> hence set the max transfer size to inform spi clients that they need
> to do something smarter.
> 
> This was uncovered by the drm_mipi_dbi spi panel code, which does
> large spi transfers, but stopped splitting them after:
> 
> commit e143364b4c1774f68e923a5a0bb0fca28ac25888
> Author: Noralf Trønnes <noralf@tronnes.org>
> Date:   Fri Jul 19 17:59:10 2019 +0200
> 
>     drm/tinydrm: Remove tinydrm_spi_max_transfer_size()
> 
> After this commit the code relied on the spi core to split transfers
> into max dma-able blocks, which also papered over the PIO fallback issue.
> 
> Fix this by setting the overall max transfer size to the DMA limit,
> but only when the controller runs in DMA mode.
> 
> Fixes: e143364b4c17 ("drm/tinydrm: Remove tinydrm_spi_max_transfer_size()")
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
> Reported-and-tested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-spi@vger.kernel.org
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/spi/spi-pxa2xx.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
> index bb6a14d1ab0f..f77201915033 100644
> --- a/drivers/spi/spi-pxa2xx.c
> +++ b/drivers/spi/spi-pxa2xx.c
> @@ -1707,6 +1707,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
>  		} else {
>  			controller->can_dma = pxa2xx_spi_can_dma;
>  			controller->max_dma_len = MAX_DMA_LEN;
> +			controller->max_transfer_size = MAX_DMA_LEN;

As Andy mentioned, ->max_transfer_size is a callback:

struct spi_controller {
	/*
	 * on some hardware transfer / message size may be constrained
	 * the limit may depend on device transfer settings
	 */
	size_t (*max_transfer_size)(struct spi_device *spi);

(I looked at its users and they all return a static or probe time value
so not sure why it's a callback.)

Noralf.

>  		}
>  	}
>  
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-16 21:30 ` Noralf Trønnes
@ 2019-10-16 21:49   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-10-16 21:49 UTC (permalink / raw)
  To: Noralf Trønnes
  Cc: linux-arm-kernel, Andy Shevchenko, Daniel Vetter, Robert Jarzmik,
	Haojian Zhuang, linux-spi, DRI Development, Sam Ravnborg,
	Daniel Mack


[-- Attachment #1.1: Type: text/plain, Size: 767 bytes --]

On Wed, Oct 16, 2019 at 11:30:51PM +0200, Noralf Trønnes wrote:

> As Andy mentioned, ->max_transfer_size is a callback:

> struct spi_controller {
> 	/*
> 	 * on some hardware transfer / message size may be constrained
> 	 * the limit may depend on device transfer settings
> 	 */
> 	size_t (*max_transfer_size)(struct spi_device *spi);

> (I looked at its users and they all return a static or probe time value
> so not sure why it's a callback.)

Huh, I wonder why we did that...  I can't find any clear record, and
like you say nothing is using it so we should probably fix it - however
that's best done separately to this :/  Sorry for the confusion, I
didn't register what Andy was saying as being pointing out the current
state of the code.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-16 19:57 [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode Daniel Vetter
  2019-10-16 21:30 ` Noralf Trønnes
@ 2019-10-17  6:44 ` Daniel Vetter
  2019-10-17  7:06   ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2019-10-17  6:44 UTC (permalink / raw)
  To: DRI Development
  Cc: linux-arm-kernel, Andy Shevchenko, Daniel Vetter, Robert Jarzmik,
	Haojian Zhuang, linux-spi, Noralf Trønnes, Mark Brown,
	Sam Ravnborg, Daniel Mack

In DMA mode we have a maximum transfer size, past that the driver
falls back to PIO (see the check at the top of pxa2xx_spi_transfer_one).
Falling back to PIO for big transfers defeats the point of a dma engine,
hence set the max transfer size to inform spi clients that they need
to do something smarter.

This was uncovered by the drm_mipi_dbi spi panel code, which does
large spi transfers, but stopped splitting them after:

commit e143364b4c1774f68e923a5a0bb0fca28ac25888
Author: Noralf Trønnes <noralf@tronnes.org>
Date:   Fri Jul 19 17:59:10 2019 +0200

    drm/tinydrm: Remove tinydrm_spi_max_transfer_size()

After this commit the code relied on the spi core to split transfers
into max dma-able blocks, which also papered over the PIO fallback issue.

Fix this by setting the overall max transfer size to the DMA limit,
but only when the controller runs in DMA mode.

Fixes: e143364b4c17 ("drm/tinydrm: Remove tinydrm_spi_max_transfer_size()")
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Reported-and-tested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
--
v2: Brown paper bag edition, it needs to be a function ...
---
 drivers/spi/spi-pxa2xx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index bb6a14d1ab0f..068c21037679 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1602,6 +1602,11 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller,
 	return cs;
 }
 
+static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi)
+{
+	return MAX_DMA_LEN;
+}
+
 static int pxa2xx_spi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -1707,6 +1712,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
 		} else {
 			controller->can_dma = pxa2xx_spi_can_dma;
 			controller->max_dma_len = MAX_DMA_LEN;
+			controller->max_transfer_size =
+				pxa2xx_spi_max_dma_transfer_size;
 		}
 	}
 
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-17  6:44 ` Daniel Vetter
@ 2019-10-17  7:06   ` Andy Shevchenko
  2019-10-21 11:08     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2019-10-17  7:06 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-arm-kernel, Sam Ravnborg, Mark Brown, Haojian Zhuang,
	linux-spi, DRI Development, Robert Jarzmik, Daniel Mack

On Thu, Oct 17, 2019 at 08:44:26AM +0200, Daniel Vetter wrote:
> In DMA mode we have a maximum transfer size, past that the driver
> falls back to PIO (see the check at the top of pxa2xx_spi_transfer_one).
> Falling back to PIO for big transfers defeats the point of a dma engine,
> hence set the max transfer size to inform spi clients that they need
> to do something smarter.
> 
> This was uncovered by the drm_mipi_dbi spi panel code, which does
> large spi transfers, but stopped splitting them after:
> 
> commit e143364b4c1774f68e923a5a0bb0fca28ac25888
> Author: Noralf Trønnes <noralf@tronnes.org>
> Date:   Fri Jul 19 17:59:10 2019 +0200
> 
>     drm/tinydrm: Remove tinydrm_spi_max_transfer_size()
> 
> After this commit the code relied on the spi core to split transfers
> into max dma-able blocks, which also papered over the PIO fallback issue.
> 
> Fix this by setting the overall max transfer size to the DMA limit,
> but only when the controller runs in DMA mode.
> 

Thank you, Daniel!

> Fixes: e143364b4c17 ("drm/tinydrm: Remove tinydrm_spi_max_transfer_size()")
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
> Reported-and-tested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-spi@vger.kernel.org
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> --
> v2: Brown paper bag edition, it needs to be a function ...
> ---
>  drivers/spi/spi-pxa2xx.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
> index bb6a14d1ab0f..068c21037679 100644
> --- a/drivers/spi/spi-pxa2xx.c
> +++ b/drivers/spi/spi-pxa2xx.c
> @@ -1602,6 +1602,11 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller,
>  	return cs;
>  }
>  
> +static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi)
> +{
> +	return MAX_DMA_LEN;
> +}
> +
>  static int pxa2xx_spi_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -1707,6 +1712,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
>  		} else {
>  			controller->can_dma = pxa2xx_spi_can_dma;
>  			controller->max_dma_len = MAX_DMA_LEN;
> +			controller->max_transfer_size =
> +				pxa2xx_spi_max_dma_transfer_size;
>  		}
>  	}
>  
> -- 
> 2.23.0
> 

-- 
With Best Regards,
Andy Shevchenko


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-17  7:06   ` Andy Shevchenko
@ 2019-10-21 11:08     ` Andy Shevchenko
  2019-10-21 11:35       ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2019-10-21 11:08 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-arm-kernel, Sam Ravnborg, Mark Brown, Haojian Zhuang,
	linux-spi, Noralf Trønnes, DRI Development, Robert Jarzmik,
	Daniel Mack

On Thu, Oct 17, 2019 at 10:06:38AM +0300, Andy Shevchenko wrote:
> On Thu, Oct 17, 2019 at 08:44:26AM +0200, Daniel Vetter wrote:
> > In DMA mode we have a maximum transfer size, past that the driver
> > falls back to PIO (see the check at the top of pxa2xx_spi_transfer_one).
> > Falling back to PIO for big transfers defeats the point of a dma engine,
> > hence set the max transfer size to inform spi clients that they need
> > to do something smarter.
> > 
> > This was uncovered by the drm_mipi_dbi spi panel code, which does
> > large spi transfers, but stopped splitting them after:
> > 
> > commit e143364b4c1774f68e923a5a0bb0fca28ac25888
> > Author: Noralf Trønnes <noralf@tronnes.org>
> > Date:   Fri Jul 19 17:59:10 2019 +0200
> > 
> >     drm/tinydrm: Remove tinydrm_spi_max_transfer_size()
> > 
> > After this commit the code relied on the spi core to split transfers
> > into max dma-able blocks, which also papered over the PIO fallback issue.
> > 
> > Fix this by setting the overall max transfer size to the DMA limit,
> > but only when the controller runs in DMA mode.
> > 
> 
> Thank you, Daniel!

Mark, can be this applied?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode
  2019-10-21 11:08     ` Andy Shevchenko
@ 2019-10-21 11:35       ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-10-21 11:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-arm-kernel, Daniel Vetter, Robert Jarzmik, Haojian Zhuang,
	linux-spi, DRI Development, Sam Ravnborg, Daniel Mack


[-- Attachment #1.1: Type: text/plain, Size: 883 bytes --]

On Mon, Oct 21, 2019 at 02:08:57PM +0300, Andy Shevchenko wrote:

> Mark, can be this applied?

b2662a164f9dc48d

Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so 
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review.  If there have been
review comments then people may be waiting for those to be addressed.

Sending content free pings adds to the mail volume (if they are seen at
all) which is often the problem and since they can't be reviewed
directly if something has gone wrong you'll have to resend the patches
anyway, so sending again is generally a better approach though there are
some other maintainers who like them - if in doubt look at how patches
for the subsystem are normally handled.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-10-21 11:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 19:57 [PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode Daniel Vetter
2019-10-16 21:30 ` Noralf Trønnes
2019-10-16 21:49   ` Mark Brown
2019-10-17  6:44 ` Daniel Vetter
2019-10-17  7:06   ` Andy Shevchenko
2019-10-21 11:08     ` Andy Shevchenko
2019-10-21 11:35       ` Mark Brown

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