From patchwork Thu Apr 11 16:42:32 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: 10896421 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 1107F1805 for ; Thu, 11 Apr 2019 16:43:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2CC928D87 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF64228DAA; Thu, 11 Apr 2019 16:43:01 +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 6C9CB28DA4 for ; Thu, 11 Apr 2019 16:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:35024 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbfDKQm7 (ORCPT ); Thu, 11 Apr 2019 12:42:59 -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=FvoADPq/n4xXPj7cNGr4e33k1SrdrQABkeQ33wdQNLQk1scTY4EyfONjVet1NKtGkqUug0VX7TD250L1rVs/jF4ZdTokEi9MDA6Cd6qUR1SW55VxlL8FukXHjFcpxIzlRVFKMWuyv+bLtU0ckwhoCnsndEnPKQGI2VFmrncYEL5etH4LvkSWqjRK0WUGP2PPJcInL+VtV9Cx+mblN+WUjG4VHajFajyy+XZx1I8FpvMN5RqtA/ITswvYhD3MxiXb0okX50vhANFRRWIzD289BEAgIzcXSbpImfh+UlASSPh8LlkEIFYwUrdGVGtAXOmd4i+s+Rc8GxOaNP58QyCLRA==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:49732 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 1hEcmv-0007LK-D0; Thu, 11 Apr 2019 18:42:57 +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, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v4 1/4] spi: Remove warning in spi_split_transfers_maxsize() Date: Thu, 11 Apr 2019 18:42:32 +0200 Message-Id: <20190411164235.49771-2-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190411164235.49771-1-noralf@tronnes.org> References: <20190411164235.49771-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 Thu Apr 11 16:42:33 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: 10896417 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 8A0561515 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7314628D79 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64EB728DB9; Thu, 11 Apr 2019 16:43:01 +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 0A4CA28D97 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:45302 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -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=z/HcVwwA5IlpWJbcKiQwGFrR+4HNdJ3XZao+2cFtF20=; b=JsfcDBiGzaaXIeMLOkh4OCElWrs2cyr5MWFwfCUoVrUPHHkhadPiDftrFg5musNlwDwCLuQjFRQ4egTnH7O6a6hjVa90ngees7zgd0aUM8Crl8acAiObocKAFUA5GNuq6r/7qe+CcVcD8bo3oLQu7b0a6S9RELrbdB0os0GZ7D5Uk9+n/FFBnJxo+yvQWnIGNLkKsULatuy2AaEFpx8w46pqDtlub61NEPgFHTODy7pv7WLt5VVyvxQfu+ZdK7tyHgNUe0qOa64jdWFAwkw1Vb6/XAxpOpiiYL1bCvCzNJwgosSpe2jEwppYP3nQ5rfJubm3al7x8As7hT7Wzd/h+A==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:49732 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 1hEcmv-0007LK-Na; Thu, 11 Apr 2019 18:42:57 +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, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v4 2/4] spi: Split spi message into max_dma_len size chunks Date: Thu, 11 Apr 2019 18:42:33 +0200 Message-Id: <20190411164235.49771-3-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190411164235.49771-1-noralf@tronnes.org> References: <20190411164235.49771-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 Some drivers like spi_bcm2835 have a max size on DMA transfers. Work around this by splitting up the transfer if necessary. ->max_transfer_size is MAX_INT if the driver doesn't set it, so this change will only affect drivers that set the value. Signed-off-by: Meghana Madhyastha Signed-off-by: Noralf Trønnes --- drivers/spi/spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 05875e63be43..22bc658032b3 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1299,6 +1299,11 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) trace_spi_message_start(ctlr->cur_msg); + ret = spi_split_transfers_maxsize(ctlr, ctlr->cur_msg, ctlr->max_dma_len, + GFP_KERNEL | GFP_DMA); + if (ret) + goto out; + if (ctlr->prepare_message) { ret = ctlr->prepare_message(ctlr, ctlr->cur_msg); if (ret) { From patchwork Thu Apr 11 16:42:34 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: 10896419 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 C0503186D for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA55028D75 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A870A28DB3; Thu, 11 Apr 2019 16:43:01 +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 4A9B228D9B for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:57362 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -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=vApEtAq5eR6HIro8BjCyMwhBiFvzodh44LJBX1/KZfM=; b=SDvfXwK7TFALG8wYWfYpDS+nlxMKcHxukZT9thx7BO7FXAaAmPKcXE9LxoWdUs9tMzr9pbttA0gFsO+YFV86xggSj9xRQ2m/DoDuE0Hqb71/wE59NZG22p44R/vC28hA3+ZRpGHkaMlf6ECRcyecJtTcau8PpoR4qQKnKG9VdazigFEp1G/ZcC7A0iWs4QQFT2z/dIC1L7m15aJj2MCOHzXHm+utTRj4quFqOouUXIxspOxM2X1KdnNYtBsXz3JR6KhTVFPJ9zVT7U+4afPzAW8K/UNadCuOGyl2WWuwew6y+VZmXAX1NnQBrNxhEQMXngBWGxEZn6pW5PypAUBVYA==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:49732 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 1hEcmw-0007LK-1I; Thu, 11 Apr 2019 18:42:58 +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, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v4 3/4] spi/spi-bcm2835: Remove DMA transfer size cap Date: Thu, 11 Apr 2019 18:42:34 +0200 Message-Id: <20190411164235.49771-4-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190411164235.49771-1-noralf@tronnes.org> References: <20190411164235.49771-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 The spi core splits up transfers larger than ->max_dma_len now so we can remove the upper bound on DMA transfers. Limit max_dma_len to 65532, because the scatter gather segment is required to be a multiple of 4. Signed-off-by: Meghana Madhyastha Signed-off-by: Noralf Trønnes --- drivers/spi/spi-bcm2835.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 35aebdfd3b4e..caf33da01ac1 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -630,19 +630,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 +694,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; From patchwork Thu Apr 11 16:42:35 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: 10896425 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 387381390 for ; Thu, 11 Apr 2019 16:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2413B28D78 for ; Thu, 11 Apr 2019 16:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10DA028D9B; Thu, 11 Apr 2019 16:43:03 +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 2A54528D78 for ; Thu, 11 Apr 2019 16:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:36940 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfDKQnA (ORCPT ); Thu, 11 Apr 2019 12:43:00 -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=QWtEYgI8wpO/amyXh2+O3vUsaFI9wgZy356WXZyZf94=; b=Lnsa7mF36taXu4e8rhE3vQjq8TRsPkDtoF1ffcV3aivO6S7RRlyOYy65V5TGu4/jAhCq9dJVz9sEv5dh3IoyMGdIbA2PK0iz+ixe2XhJgVOW518yGFR8yFPGrTyO+hBUWLnXoKL0ccbpEjYZE+t0vgYy4ANpLlSfamMKq6lLnQM35SXbz0xlWFZ8Gg7lvPArj24vWIWzlzm4wqkAdfpMWFf4SpZC9CaiIbTAjlflH0l50h+5srlc/xn1YbnuXRXzd+863szsv06qwaiiWa+cWS1RbGg9tAVCbmML31TukWz/WzUHdSKHDKTAlmF9yJj2zGO6FqcXtHgGto4ys9wvGg==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:49732 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 1hEcmw-0007LK-BG; Thu, 11 Apr 2019 18:42:58 +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, linux-rpi-kernel@lists.infradead.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH v4 4/4] drm/tinydrm: Remove chunk splitting in tinydrm_spi_transfer Date: Thu, 11 Apr 2019 18:42:35 +0200 Message-Id: <20190411164235.49771-5-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190411164235.49771-1-noralf@tronnes.org> References: <20190411164235.49771-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 the spi core will split a buffer into max_dma_len chunks for the spi controller driver to handle, 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; }