[PATCH] spi: pxa2xx: Set controller->max_transfer_size in dma mode

Andy Shevchenko andriy.shevchenko at intel.com
Thu Oct 17 07:06:38 UTC 2019


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 at 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 at ravnborg.org>
> Cc: Noralf Trønnes <noralf at tronnes.org>
> Cc: Andy Shevchenko <andriy.shevchenko at intel.com>
> Reported-and-tested-by: Andy Shevchenko <andriy.shevchenko at intel.com>
> Cc: Daniel Mack <daniel at zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang at gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik at free.fr>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-spi at vger.kernel.org
> Signed-off-by: Daniel Vetter <daniel.vetter at 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




More information about the dri-devel mailing list