From patchwork Sat Feb 24 18:16:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meghana Madhyastha X-Patchwork-Id: 10240447 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 89169602B8 for ; Sat, 24 Feb 2018 18:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA0B2950F for ; Sat, 24 Feb 2018 18:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F53929B44; Sat, 24 Feb 2018 18:16:54 +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 E1B0B2950F for ; Sat, 24 Feb 2018 18:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751414AbeBXSQx (ORCPT ); Sat, 24 Feb 2018 13:16:53 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33692 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbeBXSQw (ORCPT ); Sat, 24 Feb 2018 13:16:52 -0500 Received: by mail-pl0-f66.google.com with SMTP id c11-v6so3420006plo.0 for ; Sat, 24 Feb 2018 10:16:52 -0800 (PST) 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=2wmcnHcHNSmdadSdsjoJ5RFfJwHnx3pX5/nKQAYGsWc=; b=gdH5n1uJzl7BW+HDNbDuptu7JyX3+DT1iHqZwA4Dr/ss0kHgzyXQHosPCa0hpoo8RU I20ReZhNern/e8zx7uuyAFEWOGyhvx3/ANPjfKWWZHiJufZ1GozmGkj9vn8e21V2XnOi mF9Zj64H91DpNGr81MwTxOKFnJamnpMWOCWr7sec3sFExsi1efEQneNe7/JVvVu1z2gQ Hh3eTIrP47DeuDaBYlXqbnZNo/4mMtlf2MEBMA898uhU+PM5+qKT8/IxAyOucQo1OnWY scvmFIT1xDB989KGNNfuCN1fdWbgNzERpuFT1JTkr2EjZx5XCvppVwIEjUfaCgUIU5wo adig== 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=2wmcnHcHNSmdadSdsjoJ5RFfJwHnx3pX5/nKQAYGsWc=; b=lOYLcJudWRZ8AeJnazkdTPNTs/V3wx92DYAtv1W4c2joN2NdLVOdZk0E+MUTXxAK/q gb4e5TVQk9O+2h2+UDsOuGGmJUVCLzMAB5+/FLedhfYqr6ir/z/hhlhysgeEPtFXWBgu x1dS9RgHdOyXpM/DNnwthKbRjnpZh+PmWJxo1uSEsouxLgKWianPUDWncn/9UAQBVndA MQoyYgY/tohcp5bFnjM60GUvi447Fy1kSuNba5nHMbqgJ3JtJ0PpiYOWiD2d37JqdFKc aAx1EpLjkYwexJ4nzOi/Kh3IJZPgOHDVSTymaFvGgETuVeSZPwUq9IpuynsEcnIvL4Nk 2m/A== X-Gm-Message-State: APf1xPCyZmyj6jugniUp4Fq6oSQIjBHxuPj3NZ4thP+40PawovDFV6Ud 80AWCe5Ybs68rWcelOvLXqdqkA== X-Google-Smtp-Source: AH8x224pLt1mSlxuPEO8AmfWpcMJruIcnBczCSUKJij9TiPCNzgwBisVUcd3un46Cha4L3GeV/W2/Q== X-Received: by 2002:a17:902:e83:: with SMTP id 3-v6mr5504895plx.158.1519496212029; Sat, 24 Feb 2018 10:16:52 -0800 (PST) Received: from raspberrypi ([122.167.31.206]) by smtp.gmail.com with ESMTPSA id s9sm5722375pfa.166.2018.02.24.10.16.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Feb 2018 10:16:51 -0800 (PST) Date: Sat, 24 Feb 2018 18:16:46 +0000 From: Meghana Madhyastha To: Daniel Vetter , linux-spi@vger.kernel.org, Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Sean Paul , dri-devel@lists.freedesktop.org, kernel@martin.sperl.org Subject: [PATCH v2 1/2] drm/tinydrm: Remove chunk splitting in tinydrm_spi_transfer Message-ID: <641c51d452648aba2fb2b0b707dc780970eaaf99.1519492575.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 -Remove chunk splitting in tinydrm_spi_transfer in tinydrm-helpers as The spi core will split a buffer into max_dma_len chunks for the spi controller driver to handle. -Remove automatic byte swapping in tinydrm_spi_transfer as it doesn't have users. -Remove the upper bound check on dma transfer length in bcm2835_spi_can_dma(). Signed-off-by: Meghana Madhyastha --- drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 48 ++++---------------------- drivers/gpu/drm/tinydrm/mipi-dbi.c | 10 ++---- drivers/spi/spi-bcm2835.c | 15 +------- 3 files changed, 9 insertions(+), 64 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c index bf96072d1b97..6064099e8e63 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c @@ -452,62 +452,26 @@ int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz, struct spi_transfer tr = { .bits_per_word = bpw, .speed_hz = speed_hz, + .tx_buf = buf, + .len = len }; struct spi_message m; - u16 *swap_buf = NULL; size_t max_chunk; - size_t chunk; - int ret = 0; - if (WARN_ON_ONCE(bpw != 8 && bpw != 16)) - return -EINVAL; - - max_chunk = tinydrm_spi_max_transfer_size(spi, 0); + max_chunk = SIZE_MAX; if (drm_debug & DRM_UT_DRIVER) pr_debug("[drm:%s] bpw=%u, max_chunk=%zu, transfers:\n", - __func__, bpw, max_chunk); - - if (bpw == 16 && !tinydrm_spi_bpw_supported(spi, 16)) { - tr.bits_per_word = 8; - if (tinydrm_machine_little_endian()) { - swap_buf = kmalloc(min(len, max_chunk), GFP_KERNEL); - if (!swap_buf) - return -ENOMEM; - } - } + __func__, bpw, max_chunk); spi_message_init(&m); if (header) spi_message_add_tail(header, &m); spi_message_add_tail(&tr, &m); - while (len) { - chunk = min(len, max_chunk); - - tr.tx_buf = buf; - tr.len = chunk; - - if (swap_buf) { - const u16 *buf16 = buf; - unsigned int i; - - for (i = 0; i < chunk / 2; i++) - swap_buf[i] = swab16(buf16[i]); - - tr.tx_buf = swap_buf; - } - - buf += chunk; - len -= chunk; - - tinydrm_dbg_spi_message(spi, &m); - ret = spi_sync(spi, &m); - if (ret) - return ret; - } + tinydrm_dbg_spi_message(spi, &m); - return 0; + return spi_sync(spi, &m); } EXPORT_SYMBOL(tinydrm_spi_transfer); diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 75dd65c57e74..c8af2d65c2ad 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -886,15 +886,9 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 cmd, int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, struct gpio_desc *dc) { - size_t tx_size = tinydrm_spi_max_transfer_size(spi, 0); struct device *dev = &spi->dev; int ret; - if (tx_size < 16) { - DRM_ERROR("SPI transmit buffer too small: %zu\n", tx_size); - return -EINVAL; - } - /* * Even though it's not the SPI device that does DMA (the master does), * the dma mask is necessary for the dma_alloc_wc() in @@ -924,8 +918,8 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, mipi->swap_bytes = true; } else { mipi->command = mipi_dbi_typec1_command; - mipi->tx_buf9_len = tx_size; - mipi->tx_buf9 = devm_kmalloc(dev, tx_size, GFP_KERNEL); + mipi->tx_buf9_len = SZ_16K; + mipi->tx_buf9 = devm_kmalloc(dev, mipi->tx_buf9_len, GFP_KERNEL); if (!mipi->tx_buf9) return -ENOMEM; } diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index f35cc10772f6..2fd650891c07 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 = 65528; /* 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;