From patchwork Fri Feb 17 10:38:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9579555 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 A415E600F6 for ; Fri, 17 Feb 2017 10:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9598D280B0 for ; Fri, 17 Feb 2017 10:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A84528383; Fri, 17 Feb 2017 10:38:45 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 340A1280B0 for ; Fri, 17 Feb 2017 10:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754268AbdBQKio (ORCPT ); Fri, 17 Feb 2017 05:38:44 -0500 Received: from mail-wr0-f172.google.com ([209.85.128.172]:34771 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932556AbdBQKin (ORCPT ); Fri, 17 Feb 2017 05:38:43 -0500 Received: by mail-wr0-f172.google.com with SMTP id z61so27423660wrc.1 for ; Fri, 17 Feb 2017 02:38:43 -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=xSRvvJJsWqhROiaV7LhZf2ItE2V1oQDQ0ucmOI1d1mY=; b=eioD1V9HpbZAYosEV2kqpHcgG8hZDHAvhC294ivK73ArSO1DjX81ktlrTHd01+Sudf Qvh1YTyt9NbwlK0Jk1g4pgKc5z1SbPRXreQ8MwrYLpmmZFTZKsi5fUYO0J5f/v4J+sKs MO23+NPsRwHGI0mYXvCooN2MRMktuLCmDT9lXQ3QNMmLe1OS53w0hSw0g+A4TEKO7eKC gsKnyBuA/nfISXridSsdAt9/NJDoQyPsn8GXyRBmIifu425bFqWkzZbh/uwHLRnHIFFC BpeBXr3Z7A+cdePrOpNEZMnW9YZwSxdr04g0A3n1HJGHw0+IlCyeetLl3heVd8v0/n2m KOjQ== 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=xSRvvJJsWqhROiaV7LhZf2ItE2V1oQDQ0ucmOI1d1mY=; b=f3zxTIkS/t4Pw7t0mkkwa4yrNZx+JvVNPpnNZRgyErsWGSl9VIN844Bq6PzErHxsuY lI5d+y0cg/d8y/yNGPlOFunT56MaFji29N/1NhzZJDCfJa/FfWCWv5ZadVJWli2OpCMZ Ui5HdTHD6v7fidyKxXAHHUpr6TmpzJnZ96hs1fPDp0BL/gfV6sO4qz5wpeAzk038xtgz nMGq4kg44RS1PtCGHRjLXHdDCCp8slmHlKz8ITKd2HzxKQDVx8TlzwuoMBMF/N2JkcQP 9gPrFvvd4aogPcQmDNwitHIkaMpuurhWPqY5GT7NrErHVDChn2llackGN/ymISVGvU+s Ui4A== X-Gm-Message-State: AMke39mN3I4oRWucqTMm5SfvxTtNMowlZhRd9708bz2SEAut4kBDLgOcwYI6g8Z3howjpkk3 X-Received: by 10.223.164.66 with SMTP id e2mr5692680wra.47.1487327922475; Fri, 17 Feb 2017 02:38:42 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y80sm12531459wrb.12.2017.02.17.02.38.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 02:38:42 -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 v2 5/6] spi: davinci: do not use DMA if transfer length is less than 16 Date: Fri, 17 Feb 2017 11:38:23 +0100 Message-Id: <1487327904-28311-6-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487327904-28311-1-git-send-email-fisaksen@baylibre.com> References: <1487327904-28311-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index b69a370..826bff1 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 int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) @@ -622,10 +624,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); @@ -706,7 +707,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 (is_vmalloc_addr(t->rx_buf)) /* VIVT cache: invalidate since addr. may be aliased */