From patchwork Sat Apr 13 18:24:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10899585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DAFF1515 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D99428C07 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E6F4285A7; Sat, 13 Apr 2019 18:25:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 17A7C285A7 for ; Sat, 13 Apr 2019 18:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbfDMSZI (ORCPT ); Sat, 13 Apr 2019 14:25:08 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:32969 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbfDMSZI (ORCPT ); Sat, 13 Apr 2019 14:25:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=XrJYpk2fJvP/Fy8sC9TWU6ZvONB4MHtoNqzHilTJUYY=; b=sEASDt+3hjxBZXxGPMh9rCSsTCzNNWukCi0SrLWtSEaqKyI1ftmdaZTPXRu9R1z88PIeZrRxEL0P2+nFDKi9rvFpIPuNMemmV8xTQKteuVpM9MQcPXky12Ft3b5Yn7g799CZLZWy3cOWRMPK3UUI6YOn4HmHWoSQneS9D0sx8STz/CPpVYenbAkI9bakrRvQ646rfIIuCtYug7eZ3jcUuyH34YrzQQ1tWQliBDAea6fe6NCyXKzC0JqM2WgT4F6H4EI+/8zkcOkVg8tgfS4Zu6vAowTTP1Yj+RAKacOSlBGVcyk4tJZERVOMPavr8zW7hyCpcfgBKhXtjl4A9jEXdA==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:48766 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1hFNKr-0005SF-MQ; Sat, 13 Apr 2019 20:25:05 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: broonie@kernel.org, eric@anholt.net, stefan.wahren@i2se.com, kernel@martin.sperl.org, meghana.madhyastha@gmail.com, lukas@wunner.de, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v5 1/4] spi: Remove warning in spi_split_transfers_maxsize() Date: Sat, 13 Apr 2019 20:24:12 +0200 Message-Id: <20190413182415.38543-2-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190413182415.38543-1-noralf@tronnes.org> References: <20190413182415.38543-1-noralf@tronnes.org> MIME-Version: 1.0 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 Don't warn about splitting transfers, the info is available in the statistics if needed. Signed-off-by: Noralf Trønnes --- drivers/spi/spi.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9a7def7c3237..05875e63be43 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2692,11 +2692,6 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr, size_t offset; size_t count, i; - /* warn once about this fact that we are splitting a transfer */ - dev_warn_once(&msg->spi->dev, - "spi_transfer of length %i exceed max length of %zu - needed to split transfers\n", - xfer->len, maxsize); - /* calculate how many we have to replace */ count = DIV_ROUND_UP(xfer->len, maxsize); From patchwork Sat Apr 13 18:24:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10899589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A841C17EF for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 906EE285A7 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84F7828C52; Sat, 13 Apr 2019 18:25:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 6337628678 for ; Sat, 13 Apr 2019 18:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbfDMSZI (ORCPT ); Sat, 13 Apr 2019 14:25:08 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:38907 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbfDMSZI (ORCPT ); Sat, 13 Apr 2019 14:25:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=2Ehwa75Md1cc+/iOnHSvQN/8BQVqmYHDJqCcpoJD9p4=; b=bCXCBBp2hC5L5fnBUpw0XtFcU0oAYfgxtnOg44DgIMV0iQhxD84C27m+kzkEqDHkoePctEBH5+K+jPXlzI4XhX28gPdjqO66nyRS24dyC2PCb2nC9rIQGFwPeDvyDCm4gSkF64jRk1b4RAS0526EXjRuk3paJNJrFIvaTQcxbgoAohpnqk9Ayjpgq2imNkJWCxRFsl8hrq7G41smM30c8wLBHQNhR+YnmDFhg0VDCDdcBo8voSpBGZKEWHK8cDhrzxaT7gnVD+bTVPDRAMceexAQvCkO/KBqM2AwCs2DUEu1QFJOXWQ5QLvmQ7+81dR/Nyevq5puDHnebiNA19V09w==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:48766 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1hFNKs-0005SF-1E; Sat, 13 Apr 2019 20:25:06 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: broonie@kernel.org, eric@anholt.net, stefan.wahren@i2se.com, kernel@martin.sperl.org, meghana.madhyastha@gmail.com, lukas@wunner.de, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v5 2/4] spi: Release spi_res after finalizing message Date: Sat, 13 Apr 2019 20:24:13 +0200 Message-Id: <20190413182415.38543-3-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190413182415.38543-1-noralf@tronnes.org> References: <20190413182415.38543-1-noralf@tronnes.org> MIME-Version: 1.0 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 spi_split_transfers_maxsize() can be used to split a transfer. This function uses spi_res to lifetime manage the added transfer structures. So in order to finalize the current message while it contains the split transfers, spi_res_release() must be called after finalizing. Signed-off-by: Noralf Trønnes --- drivers/spi/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 05875e63be43..35939ffdeebe 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1162,10 +1162,10 @@ static int spi_transfer_one_message(struct spi_controller *ctlr, if (msg->status && ctlr->handle_err) ctlr->handle_err(ctlr, msg); - spi_res_release(ctlr, msg); - spi_finalize_current_message(ctlr); + spi_res_release(ctlr, msg); + return ret; } From patchwork Sat Apr 13 18:24:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10899587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAABF186E for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE2128678 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF33C28C07; Sat, 13 Apr 2019 18:25:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 28D1528AE6 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbfDMSZJ (ORCPT ); Sat, 13 Apr 2019 14:25:09 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:55352 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfDMSZJ (ORCPT ); Sat, 13 Apr 2019 14:25:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1IjeNE+wWOLYmHhetqSE10NJZ4ye+fVTyppJIIbyng8=; b=Bqx2tPJoJNO8x9sHpRQvq6xCHxUG4JtV96erM6Auf2hDIFPF8am4KjY66q9ro8IooWgCpvVEKXI6Z3OgO+PA3jK3cWwJ8M1k6z+iT/ZfZe+lA6+8CdyUW2vflw6iZAOzGb7gWTN/7QZGlfkqQMlIiwv/w+dH/qsVP0tsp66kkExr9tK2Vs9/OB0uKjlVyQc0CekO3rg3FHHPcmvlpGMBJa+Ief1sAmHuJuk1tSWV+rhakShuMbP9MgZMTYdR3vyA+0wUz85NuB/MQOnJl9JbnE7015G+gPC2FhsCLurg0jsDiFWsFB1b6vbab5JEIhBGXeox4IzVMTCQlDAnF/S3kg==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:48766 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1hFNKs-0005SF-CK; Sat, 13 Apr 2019 20:25:06 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: broonie@kernel.org, eric@anholt.net, stefan.wahren@i2se.com, kernel@martin.sperl.org, meghana.madhyastha@gmail.com, lukas@wunner.de, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v5 3/4] spi/spi-bcm2835: Split transfers that exceed DLEN Date: Sat, 13 Apr 2019 20:24:14 +0200 Message-Id: <20190413182415.38543-4-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190413182415.38543-1-noralf@tronnes.org> References: <20190413182415.38543-1-noralf@tronnes.org> MIME-Version: 1.0 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 From: Meghana Madhyastha Split spi transfers into chunks of <=65532 to enable the driver to perform DMA transfer on big buffers. The DLEN register specifies the number of bytes to transfer in DMA mode. It is 16-bit wide and thus the maximum DMA transfer is 65535 bytes. Set the maximum to 65532 (4 byte aligned) since the FIFO in DMA mode is accessed in 4 byte chunks. ->max_dma_len is the value the spi core uses when splitting the buffer into scatter gather entries. The BCM2835 DMA block has 2 types of channels/engines: - Normal: Max length: 1G - Lite: Max length: 65535 Even when using a Lite channel we will not exceed the max length, so let's drop setting ->max_dma_len. Signed-off-by: Meghana Madhyastha Signed-off-by: Noralf Trønnes Reviewed-by: Lukas Wunner --- drivers/spi/spi-bcm2835.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 35aebdfd3b4e..8aa22713c483 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -335,20 +335,6 @@ static int bcm2835_spi_transfer_one_irq(struct spi_master *master, return 1; } -/* - * DMA support - * - * this implementation has currently a few issues in so far as it does - * not work arrount limitations of the HW. - * - * the main one being that DMA transfers are limited to 16 bit - * (so 0 to 65535 bytes) by the SPI HW due to BCM2835_SPI_DLEN - * - * there may be a few more border-cases we may need to address as well - * but unfortunately this would mean splitting up the scatter-gather - * list making it slightly unpractical... - */ - /** * bcm2835_spi_transfer_prologue() - transfer first few bytes without DMA * @master: SPI master @@ -630,19 +616,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; - } - /* return OK */ return true; } @@ -707,7 +680,6 @@ 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 */ /* need to do TX AND RX DMA, so we need dummy buffers */ master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; @@ -844,6 +816,17 @@ 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); u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS); + int ret; + + /* + * DMA transfers are limited to 16 bit (0 to 65535 bytes) by the SPI HW + * due to DLEN. Split up transfers (32-bit FIFO aligned) if the limit is + * exceeded. + */ + ret = spi_split_transfers_maxsize(master, msg, 65532, + GFP_KERNEL | GFP_DMA); + if (ret) + return ret; cs &= ~(BCM2835_SPI_CS_CPOL | BCM2835_SPI_CS_CPHA); From patchwork Sat Apr 13 18:24:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10899591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29EBF18B7 for ; Sat, 13 Apr 2019 18:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E974C28BC4 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD51E28660; Sat, 13 Apr 2019 18:25:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 49FC828C51 for ; Sat, 13 Apr 2019 18:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfDMSZJ (ORCPT ); Sat, 13 Apr 2019 14:25:09 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:35972 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbfDMSZJ (ORCPT ); Sat, 13 Apr 2019 14:25:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=3Y1IxRXFOOIa+RsVhvks/0XBKK+13WLS553sNdJX+68=; b=dVy2qBCdq7zeCMOxBi7HN+SiqFVidjIKjKtoR26ndNqA2fUjOWDKF95T15wjM++g/H0vqtqfIQpoCCHrY4Ys6/25G0L2ivluvgxueBeOniTqGdGcVoJls/PDxTmCepz8bI0dxvH3WrnO2AEykOz7h9UXW3L/WYSE/ne4MjcRK96Mo7AG5jwL0Pm6uxgvI1h80Eyxr6jiUVZSekFTQv3Lplpp4biHSxRAghgRoOczENyNMfJCimWLKWMYC+wPm/VoPpk4QZ4u00JSGUeKDFBrqULqdTwS0W+HYWpoPPnT+NdDPY9XbXY/ed6bhx/zFmIgMHuyuHLquje94WE2URZZ9A==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:48766 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1hFNKs-0005SF-Oo; Sat, 13 Apr 2019 20:25:06 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: broonie@kernel.org, eric@anholt.net, stefan.wahren@i2se.com, kernel@martin.sperl.org, meghana.madhyastha@gmail.com, lukas@wunner.de, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v5 4/4] drm/tinydrm: Remove chunk splitting in tinydrm_spi_transfer Date: Sat, 13 Apr 2019 20:24:15 +0200 Message-Id: <20190413182415.38543-5-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190413182415.38543-1-noralf@tronnes.org> References: <20190413182415.38543-1-noralf@tronnes.org> MIME-Version: 1.0 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 From: Meghana Madhyastha Remove chunk splitting in tinydrm_spi_transfer in tinydrm-helpers as spi-bcm2835 now can handle large buffers using DMA, automatic byte swapping in tinydrm_spi_transfer as it doesn't have users. Remove the spi_max module argument that now has lost its cause. The 16kB buffer size for Type C Option 1 (9-bit) interface is somewhat arbitrary, but a bigger buffer will have a miniscule impact on transfer speed, so it's probably fine. Signed-off-by: Meghana Madhyastha Signed-off-by: Noralf Trønnes --- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 83 ++----------------- drivers/gpu/drm/tinydrm/mipi-dbi.c | 10 +-- 2 files changed, 7 insertions(+), 86 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c index 6d540d93758f..a32dc859a9c1 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c @@ -22,41 +22,8 @@ #include #include -static unsigned int spi_max; -module_param(spi_max, uint, 0400); -MODULE_PARM_DESC(spi_max, "Set a lower SPI max transfer size"); - #if IS_ENABLED(CONFIG_SPI) -/** - * tinydrm_spi_max_transfer_size - Determine max SPI transfer size - * @spi: SPI device - * @max_len: Maximum buffer size needed (optional) - * - * This function returns the maximum size to use for SPI transfers. It checks - * the SPI master, the optional @max_len and the module parameter spi_max and - * returns the smallest. - * - * Returns: - * Maximum size for SPI transfers - */ -size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len) -{ - size_t ret; - - ret = min(spi_max_transfer_size(spi), spi->master->max_dma_len); - if (max_len) - ret = min(ret, max_len); - if (spi_max) - ret = min_t(size_t, ret, spi_max); - ret &= ~0x3; - if (ret < 4) - ret = 4; - - return ret; -} -EXPORT_SYMBOL(tinydrm_spi_max_transfer_size); - /** * tinydrm_spi_bpw_supported - Check if bits per word is supported * @spi: SPI device @@ -147,62 +114,22 @@ 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); 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; - } - } + pr_debug("[drm:%s] bpw=%u, transfers:\n", __func__, bpw); 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); + tinydrm_dbg_spi_message(spi, &m); - 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; - } - - 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 85761b4abb83..0bcf6c764893 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -975,15 +975,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 @@ -1013,8 +1007,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; }