[PATCH v2 1/2] spi: Split spi message into chunks of <65535 in the spi subsystem

Noralf Trønnes noralf at tronnes.org
Sun Mar 11 13:33:32 UTC 2018


Den 10.03.2018 16.51, skrev Meghana Madhyastha:
> Split spi messages into chunks of <65535 in the spi subsystem and remove the message
> length warning in bcm2835_spi_can_dma. This is so that the messages can be transferred
> via dma and that the tinydrm drivers need not split it.
>
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha at gmail.com>
> ---
>   drivers/spi/spi-bcm2835.c | 13 -------------
>   drivers/spi/spi.c         |  8 ++++++++
>   2 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
> index f35cc10772f6..0dcc45f158b8 100644
> --- a/drivers/spi/spi-bcm2835.c
> +++ b/drivers/spi/spi-bcm2835.c
> @@ -365,19 +365,6 @@ static bool bcm2835_spi_can_dma(struct spi_master *master,
>   	if (tfr->len < BCM2835_SPI_DMA_MIN_LENGTH)
>   		return false;
>   
> -	/* BCM2835_SPI_DLEN has defined a max transfer size as
> -	 * 16 bit, so max is 65535
> -	 * we can revisit this by using an alternative transfer
> -	 * method - ideally this would get done without any more
> -	 * interaction...
> -	 */
> -	if (tfr->len > 65535) {
> -		dev_warn_once(&spi->dev,
> -			      "transfer size of %d too big for dma-transfer\n",
> -			      tfr->len);
> -		return false;
> -	}
> -
>   	/* if we run rx/tx_buf with word aligned addresses then we are OK */
>   	if ((((size_t)tfr->rx_buf & 3) == 0) &&
>   	    (((size_t)tfr->tx_buf & 3) == 0))
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index b33a727a0158..e8e2c366a93b 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1242,6 +1242,14 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
>   	trace_spi_message_start(ctlr->cur_msg);
>   
>   	if (ctlr->prepare_message) {
> +		gfp_t gfp_flags = GFP_KERNEL | GFP_DMA;
> +		size_t max_transfer_size = 32000;

What number is this?

As Geert says, this shouldn't be in the core but in the driver callback
bcm2835_spi_prepare_message().

Noralf.

> +		ret = spi_split_transfers_maxsize(ctlr, ctlr->cur_msg, max_transfer_size, gfp_flags);
> +		if (ret) {
> +			dev_err(&ctlr->dev,
> +				"failed to split message\n");
> +			goto out;
> +		}
>   		ret = ctlr->prepare_message(ctlr, ctlr->cur_msg);
>   		if (ret) {
>   			dev_err(&ctlr->dev, "failed to prepare message: %d\n",



More information about the dri-devel mailing list