From patchwork Mon Dec 7 15:21:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 7786511 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0C4DB9F1C2 for ; Mon, 7 Dec 2015 15:22:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EC6420396 for ; Mon, 7 Dec 2015 15:22:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45F7A204B0 for ; Mon, 7 Dec 2015 15:22:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933378AbbLGPWK (ORCPT ); Mon, 7 Dec 2015 10:22:10 -0500 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163]:38791 "EHLO cgate.sperl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933227AbbLGPWJ (ORCPT ); Mon, 7 Dec 2015 10:22:09 -0500 Received: from raspcm.intern.sperl.org (account martin@sperl.org [10.10.10.41] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6360741; Mon, 07 Dec 2015 15:21:57 +0000 From: kernel@martin.sperl.org To: Mark Brown , Stephen Warren , Lee Jones , Eric Anholt , linux-spi@vger.kernel.org, linux-rpi-kernel@lists.infradead.org Cc: Martin Sperl Subject: [PATCH V2 5/5] spi: bcm2835: split long transfers Date: Mon, 7 Dec 2015 15:21:48 +0000 Message-Id: <1449501708-2228-6-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1449501708-2228-1-git-send-email-kernel@martin.sperl.org> References: <1449501708-2228-1-git-send-email-kernel@martin.sperl.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Sperl Start to use spi_translate_message method when running in DMA mode and (for now) split spi_transfers with len > 60kB transparently into multiple transfers using the core method spi_split_transfers_maxsize. Eventually the bcm2835_translate_message may get moved into SPI-core as shared code (when we find the common denominators for different HW) Signed-off-by: Martin Sperl --- drivers/spi/spi-bcm2835.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index cf04960..03c889d 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -353,6 +353,14 @@ static int bcm2835_spi_transfer_one_dma(struct spi_master *master, return 1; } +static int bcm2835_translate_message(struct spi_master *master, + struct spi_message *message) +{ + /* translate the message */ + return spi_split_transfers_maxsize(master, message, + master->max_dma_len); +} + static bool bcm2835_spi_can_dma(struct spi_master *master, struct spi_device *spi, struct spi_transfer *tfr) @@ -365,19 +373,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 +456,15 @@ 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 */ + + /* also set up transform message */ + master->translate_message = bcm2835_translate_message; + + /* the max_dma_size limited by BCM2835_SPI_DLEN is actually 65535, + * but for al practical purposes we use 15 pages (60k) + */ + master->max_dma_len = 15 * PAGE_SIZE; + master->dma_alignment = 4; /* word alignment is recommended */ /* need to do TX AND RX DMA, so we need dummy buffers */ master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;