dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: "Meghana Madhyastha" <meghana.madhyastha@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Daniel Vetter" <daniel.vetter@intel.com>,
	linux-spi@vger.kernel.org, "Noralf Trønnes" <noralf@tronnes.org>,
	"Sean Paul" <seanpaul@chromium.org>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/2] spi: Split spi message into chunks of <65535 in the spi subsystem
Date: Fri, 16 Mar 2018 16:55:45 -0700	[thread overview]
Message-ID: <87po43vam6.fsf@anholt.net> (raw)
In-Reply-To: <648641e37f11ac4a4d94d371e7b676c5a6108edd.1520848302.git.meghana.madhyastha@gmail.com>


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

Meghana Madhyastha <meghana.madhyastha@gmail.com> writes:

> 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. The current chunk size is 65532.
> This is because the scatter gather segment is required to be multiple of 4. The size
> has to be <65535 due to hardware limitations.
>
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
> ---
>  drivers/spi/spi-bcm2835.c | 22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
> index f35cc10772f6..280ffa5aef7e 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))
> @@ -461,7 +448,7 @@ static void bcm2835_dma_init(struct spi_master *master, struct device *dev)
>  
>  	/* all went well, so set can_dma */
>  	master->can_dma = bcm2835_spi_can_dma;
> -	master->max_dma_len = 65535; /* limitation by BCM2835_SPI_DLEN */
> +	master->max_dma_len = 65532; /* limitation by BCM2835_SPI_DLEN */
>  	/* need to do TX AND RX DMA, so we need dummy buffers */
>  	master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
>  
> @@ -597,7 +584,14 @@ static int bcm2835_spi_prepare_message(struct spi_master *master,
>  {
>  	struct spi_device *spi = msg->spi;
>  	struct bcm2835_spi *bs = spi_master_get_devdata(master);
> +	gfp_t gfp_flags = GFP_KERNEL | GFP_DMA;
>  	u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS);
> +	size_t max_transfer_size = 65532;
> +	int ret;
> +
> +	ret = spi_split_transfers_maxsize(master, msg, max_transfer_size, gfp_flags);
> +	if (ret)
> +	       return ret;

Mark: is this how spi_split_transfers_maxsize() is supposed to be used?
If so, I'm happy to see our hardware have fewer limitations, and it gets
my:

Reviewed-by: Eric Anholt <eric@anholt.net>

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

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

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

  reply	other threads:[~2018-03-16 23:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12  9:53 [PATCH v3 0/2] Chunk splitting of spi transfers Meghana Madhyastha
2018-03-12  9:54 ` [PATCH v3 1/2] spi: Split spi message into chunks of <65535 in the spi subsystem Meghana Madhyastha
2018-03-16 23:55   ` Eric Anholt [this message]
2018-03-12  9:54 ` [PATCH v3 2/2] drm/tinydrm: Remove chunk splitting in tinydrm_spi_transfer Meghana Madhyastha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87po43vam6.fsf@anholt.net \
    --to=eric@anholt.net \
    --cc=broonie@kernel.org \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=meghana.madhyastha@gmail.com \
    --cc=noralf@tronnes.org \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox