From patchwork Thu Feb 23 18:01:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9588753 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 9A1E260210 for ; Thu, 23 Feb 2017 18:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6C02877E for ; Thu, 23 Feb 2017 18:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 842892878B; Thu, 23 Feb 2017 18:03:11 +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_SIGNED, 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 0D79E28788 for ; Thu, 23 Feb 2017 18:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751049AbdBWSDK (ORCPT ); Thu, 23 Feb 2017 13:03:10 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:34000 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdBWSDK (ORCPT ); Thu, 23 Feb 2017 13:03:10 -0500 Received: by mail-wm0-f53.google.com with SMTP id 196so4676102wmm.1 for ; Thu, 23 Feb 2017 10:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GmCS+XFi8aiEZZiycyJ2zNLl3q3VxKDx4tuheTfPtlk=; b=jn1LTzZiv95EDcRL/E53NWVm+4SzaveLBKMaupM0SAcI5DCSOG/AO8UStsm7rOUSW+ 7R0UNJNoohe/dIwJ+vF7RMZsvIcy4a7wahIv8L1nTzC0y4FmXOpnqtiGscfKk7Ftgrby +AJ3nyMEwDNl34/vcdcPhxgLjFP2aVpdL6A2cO2+Hm1d5PAKyZG4I2jugbiekTU2KJuJ XBeZjRi8akDO7k9FmKZsDZaPN5A3fXxDf/hY0lVERqZaTO+sBOdiGxhc8dOzoMwE4Mzv PF/9viFHAtZUc8/kMcEKU73kNV2ELqRbP38tW4MC3WX8M5dlBjHIgkqIHUQAHybpnTKx Sn5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GmCS+XFi8aiEZZiycyJ2zNLl3q3VxKDx4tuheTfPtlk=; b=uiTP+lCAMoqv/f3TGyeLwl/XPPIekpV+fOdbO8ZcmTIAHvmspzdtZVfHnwQKgEk0qw CIuYqcv30UQrE16tiAtLb2BFaS9ehtJOONigKzSXXt/1vYcT04TgHtheRfr/LpzneJFG 4mRU9SMTy/P6FynK6J6gu3zaOSuQh6EoP6r7VgAPCK1z7yiAv1JlfnVimb/JpZdf0qvW CACiET/uLc9ejgB8jwFusmcrqiIPlw9fRJg/U6G/wQ8tSKxeeldSdHxML3fYcid+U/Xd VhhdQVCZKhWaG8kJDnobxq2x4ZqzLUy5NrpX2gYIjaNS5Shsbcu7jyPgteCxTjpJP2cV ug6g== X-Gm-Message-State: AMke39ltZ7cALfMUSnS2o4WwXG3y5DNvO5tXfOmn4zSc3oz0qOXYCKvcIOSoW+ld6Hmxbtos X-Received: by 10.28.63.15 with SMTP id m15mr6295873wma.119.1487872988635; Thu, 23 Feb 2017 10:03:08 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id z134sm7739182wmc.20.2017.02.23.10.03.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Feb 2017 10:03:08 -0800 (PST) From: Frode Isaksen To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, linux-spi@vger.kernel.org, Frode Isaksen Subject: [PATCH v3 4/6] spi: davinci: do not use DMA if transfer length is less than 16 Date: Thu, 23 Feb 2017 19:01:59 +0100 Message-Id: <1487872921-26628-5-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487872921-26628-1-git-send-email-fisaksen@baylibre.com> References: <1487872921-26628-1-git-send-email-fisaksen@baylibre.com> 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 Higher bitrate and lower CPU load if using PIO in this case. Signed-off-by: Frode Isaksen --- drivers/spi/spi-davinci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index ca12216..75c658e 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -109,6 +109,8 @@ #define SPIDEF 0x4c #define SPIFMT0 0x50 +#define DMA_MIN_BYTES 16 + /* SPI Controller driver's private data. */ struct davinci_spi { struct spi_bitbang bitbang; @@ -479,7 +481,8 @@ static bool davinci_spi_can_dma(struct spi_master *master, bool can_dma = false; if (spicfg) - can_dma = spicfg->io_type == SPI_IO_TYPE_DMA; + can_dma = (spicfg->io_type == SPI_IO_TYPE_DMA) && + (xfer->len >= DMA_MIN_BYTES); return can_dma; } @@ -620,10 +623,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) reinit_completion(&dspi->done); - if (spicfg->io_type == SPI_IO_TYPE_INTR) - set_io_bits(dspi->base + SPIINT, SPIINT_MASKINT); - - if (spicfg->io_type != SPI_IO_TYPE_DMA) { + if (!davinci_spi_can_dma(spi->master, spi, t)) { + if (spicfg->io_type != SPI_IO_TYPE_POLL) + set_io_bits(dspi->base + SPIINT, SPIINT_MASKINT); /* start the transfer */ dspi->wcount--; tx_data = dspi->get_tx(dspi); @@ -698,7 +700,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) } clear_io_bits(dspi->base + SPIINT, SPIINT_MASKALL); - if (spicfg->io_type == SPI_IO_TYPE_DMA) + if (davinci_spi_can_dma(spi->master, spi, t)) clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN); clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);