From patchwork Fri Feb 10 15:29:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9567027 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 2F1D460216 for ; Fri, 10 Feb 2017 15:58:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D12628575 for ; Fri, 10 Feb 2017 15:58:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 112EE28597; Fri, 10 Feb 2017 15:58:29 +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 AB20D28575 for ; Fri, 10 Feb 2017 15:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753235AbdBJP61 (ORCPT ); Fri, 10 Feb 2017 10:58:27 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:36120 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbdBJP5n (ORCPT ); Fri, 10 Feb 2017 10:57:43 -0500 Received: by mail-wm0-f46.google.com with SMTP id c85so264052309wmi.1 for ; Fri, 10 Feb 2017 07:57:21 -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=nA2Ftlzakoc9qTm8ISBbNgoEJy9uOeWr1jkoiiZJ+Xk=; b=Qg0Kkqq0NB17lZTxwiHS5YbdJnY+uKDRMCIQ4e6DlLxY442m2t1ikYNkLJPiD/fcpf HmEvZuxspk9PAkCK057tHJhDapgdW+y61X5XRp+hY2ywAyF9lDguXoHQhUSJe4nBhhKz bP84WYF1DWIwSXkbm11eakr3IPCFhnb9KEDKSRKHycdmDe+gXy6asLIb6ajR+LxgNrkC ODk2+Vv1mFxDQ8fjxg0V4HdlYvCLj+UqvIUB1lfJkWj0J9Dm0S1V/Tl4QR4kikLNuTyo ym1NSrs+aS04Yu7jykvLeX89A2Y9R+sJWSqZQsmWcUTCXo9T9h17BjlrvLKVd50pcPEw 6vsA== 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=nA2Ftlzakoc9qTm8ISBbNgoEJy9uOeWr1jkoiiZJ+Xk=; b=Qr1GQjEzDWWf13yFtkbrWcB9EHgFUZXWqOV8YvGBI3I1bggeao32V1MLeZYw68KVEB AiSZXfFcT2nj6KeZJBryweI3cC+4vzlDNrAVp9grghMSqYs5qbr6PUquSiqDJ5ajEIAW NKQHKfbKbig6kRHeEnAtiIqafDTmO+3H7PHkxPUbUJqW2FbYZ52yxG0RQ1WrbE9oqUml Dw8255Mog657emUf0Uj06azP5lrkzTzl3ieBEGP9+g8HVt2nG6L++Q0RfQT9juW5MBi4 CZLhLVUFcdjO7J07mgozpdHqEV0EntVvOB/Fvwnil0ghz008zZoSuqA5Vkt/s/xj9lRO wwlA== X-Gm-Message-State: AMke39mNwYFxgvhyD8ndDFBEhDUr3dUoPcHxhiZN1iVTwnwL50cLC58LNYjYldvMeg2SjV+Z X-Received: by 10.28.210.65 with SMTP id j62mr7940785wmg.9.1486740644656; Fri, 10 Feb 2017 07:30:44 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id o143sm2068192wmd.3.2017.02.10.07.30.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 07:30:44 -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 5/8] spi: davinci: do not use DMA if transfer length is less than 16 Date: Fri, 10 Feb 2017 16:29:41 +0100 Message-Id: <1486740584-17875-6-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486740584-17875-1-git-send-email-fisaksen@baylibre.com> References: <1486740584-17875-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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index c735425..3c428f8 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -110,6 +110,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; @@ -483,7 +485,7 @@ static bool davinci_spi_can_dma(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) { - return __davinci_spi_can_dma(spi); + return __davinci_spi_can_dma(spi) && (xfer->len >= DMA_MIN_BYTES); } static size_t davinci_spi_max_transfer_size(struct spi_device *spi) @@ -634,10 +636,10 @@ 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); @@ -740,7 +742,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); if (!t->rx_buf)