From patchwork Mon Mar 12 09:54:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meghana Madhyastha X-Patchwork-Id: 10275841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 28C26602C2 for ; Mon, 12 Mar 2018 09:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB9228CDE for ; Mon, 12 Mar 2018 09:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0007028CE1; Mon, 12 Mar 2018 09:54:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7222928CDB for ; Mon, 12 Mar 2018 09:54:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752177AbeCLJyh (ORCPT ); Mon, 12 Mar 2018 05:54:37 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:45478 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344AbeCLJyg (ORCPT ); Mon, 12 Mar 2018 05:54:36 -0400 Received: by mail-io0-f196.google.com with SMTP id m22so10666814iob.12 for ; Mon, 12 Mar 2018 02:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vXOPhkwkMisDgeTvVhfFtjDgpakTS2PPS/NDTzv8zNA=; b=HAtgKfMQ7AjiT9V4RD/N5SYx+yLqdjK8/efSbsArvP3lpNAlOO2IQf6ErwJ9r06f4I DFibA5wYuRXN+esu5TsntnTF41Ec4Z9hFsu9k0hwgKMuiv8Mp4WtYJ7EAJXLP5kezAgm YvzqjrcZynuNlmWo7Y4aKwAr1ijqhMALcpuSI5cwWqgHgTm9shucVdrrJvCYiWr3sCJl kOSoHjResq1HsQEhyx0vWnUHBAvOWskh18v45DGWLnRCsOIzrxidCTocbwbAmbvHG/Dk PPuND0VMwuWwmhyHFDT3ujoquMzxxUebKAbx0KLDrgGf3GN4cwBejbX20v6q9ci8a/I6 Z3wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vXOPhkwkMisDgeTvVhfFtjDgpakTS2PPS/NDTzv8zNA=; b=ti7JQaLA74vPEDPA/lT3gx/snwm3+cuHVTx37gcvej2avC9XS62etEHerRJ6lc4OnF wgawmS8YlEtiKBdLC3P6jP04d4PRJrfldWGwHMV0pdte+Rl9ulbM6ePOsAQ1ZWuA9gs6 gVWlU/qJ8LWTMaY5UAYuH4wZlInhdI64Wxb+gVUxkXV6KETe00qVMafJ0fknb3w/xjQ+ RW8ZdHPkIb6Bo+Xz7mM21Lk06QEGOG08KnncRA/eKaUQHgJeb+GZEMKwJPGUTu0uTQLU EW4s7I/Sf4x+HmZztaZ3Gpk8a1qHE11AGEGg0E9dCcBhEKevZEz8MLBbUeLBzuXBAYs4 Kw5A== X-Gm-Message-State: AElRT7HkzyNrYVRnxVBaJMSNNGeJFT1bq8KJym4DIbngFi+iinOCIFOQ ttkNBgfqjeJxHn+yMGPUYFgUtg== X-Google-Smtp-Source: AG47ELsfYPWlAcktfBVslttNLcGQJNMuf+ZIuAjO7abslG3tGDI2xMQkhY9cwFzYaiO9vGA06808EQ== X-Received: by 10.107.89.4 with SMTP id n4mr8006766iob.286.1520848476075; Mon, 12 Mar 2018 02:54:36 -0700 (PDT) Received: from raspberrypi ([122.172.126.13]) by smtp.gmail.com with ESMTPSA id 15sm3262348iti.9.2018.03.12.02.54.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Mar 2018 02:54:35 -0700 (PDT) Date: Mon, 12 Mar 2018 09:54:30 +0000 From: Meghana Madhyastha To: Mark Brown , Daniel Vetter , linux-spi@vger.kernel.org, Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Sean Paul , dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/2] spi: Split spi message into chunks of <65535 in the spi subsystem Message-ID: <648641e37f11ac4a4d94d371e7b676c5a6108edd.1520848302.git.meghana.madhyastha@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Eric Anholt --- 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; cs &= ~(BCM2835_SPI_CS_CPOL | BCM2835_SPI_CS_CPHA);