From patchwork Thu May 30 05:27:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 17285 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ea0-f199.google.com (mail-ea0-f199.google.com [209.85.215.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3709425D81 for ; Thu, 30 May 2013 05:24:47 +0000 (UTC) Received: by mail-ea0-f199.google.com with SMTP id a11sf46646eae.6 for ; Wed, 29 May 2013 22:24:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:x-auditid:from:to:cc:subject:date:message-id:x-mailer :x-brightmail-tracker:x-brightmail-tracker:dlp-filter:x-mtr :x-cfilter-loop:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=7F31zdBvA+lEmEmOyVfdTxh6n/ELT6vDi4AQwsy9Enk=; b=fqFPM1uMhi1wXXaW6hQzzeXZrV0YBYDO4wI8S63PdxdbUDoBnqIDvWJy/2gnE7Wmp0 jTgvLqB67mIYJ/QBktgKI2qXKiW1klmaueTkJEBN9+fZxvXCRlftJE2Y0cm8ePlgtOUw 2At0QbVc/rSD1iKOGUT4bu6vSz4IoKEbAyPQObo4k0oPSqij+qi6EnAeVL2Ftx8GTaKp Rx3uY+ZBYfPsKO51Znt51EImWgnefWNgvDRcUbX9oLMbO3EqM+pR5qH517sGRLzdxw3H uoCbhFS+XpJNU8TbIqUrsTgziWZUMpKxqDGQK0SnueXr+0MSTQZsxUYPPVnU++UhxH8/ 5Vcg== X-Received: by 10.180.185.115 with SMTP id fb19mr8793102wic.0.1369891486102; Wed, 29 May 2013 22:24:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.74.52 with SMTP id q20ls1722083wiv.53.canary; Wed, 29 May 2013 22:24:46 -0700 (PDT) X-Received: by 10.180.198.110 with SMTP id jb14mr16868714wic.37.1369891486010; Wed, 29 May 2013 22:24:46 -0700 (PDT) Received: from mail-ve0-x22a.google.com (mail-ve0-x22a.google.com [2607:f8b0:400c:c01::22a]) by mx.google.com with ESMTPS id pm10si7614904wjb.195.2013.05.29.22.24.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 22:24:45 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22a; Received: by mail-ve0-f170.google.com with SMTP id 14so804861vea.15 for ; Wed, 29 May 2013 22:24:44 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr4039767vcb.8.1369891484478; Wed, 29 May 2013 22:24:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.229.199 with SMTP id jj7csp2068vcb; Wed, 29 May 2013 22:24:43 -0700 (PDT) X-Received: by 10.68.94.5 with SMTP id cy5mr6189227pbb.62.1369891483369; Wed, 29 May 2013 22:24:43 -0700 (PDT) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id oo1si4824746pbb.299.2013.05.29.22.24.42 for ; Wed, 29 May 2013 22:24:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MNL009GAJ0NS6L0@mailout1.samsung.com> for patches@linaro.org; Thu, 30 May 2013 14:24:41 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id A1.E4.03969.992E6A15; Thu, 30 May 2013 14:24:41 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-45-51a6e2992ee3 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D6.43.21068.992E6A15; Thu, 30 May 2013 14:24:41 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MNL002KHJ10DT20@mmp2.samsung.com>; Thu, 30 May 2013 14:24:41 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, u-boot-review@google.com, jagannadh.teki@gmail.com Subject: [PATCH V2] spi: exynos: Minimise access to SPI FIFO level Date: Thu, 30 May 2013 10:57:31 +0530 Message-id: <1369891651-28419-1-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsWyRsSkWnfmo2WBBpd3ylvs2trCatFxpIXR YsrhLywW37ZsY7RY/noju8XbvZ3sDmwesxsusnjsnHWX3WPBplKPO9f2sHmcvbOD0aNvyyrG ALYoLpuU1JzMstQifbsErozVr2axFewSrjj17h9TA+Mvvi5GTg4JAROJfdd62CBsMYkL99YD 2VwcQgJLGSU+Hm9h7WLkACs63ukEEZ/OKHGx4wkjhDORSWLHitesIN1sAkYSW09OYwSxRQQk JH71XwWzmQVKJGadPsYIMkhYwEli5xUREJNFQFVi41xJkApeAQ+JRZ8XMEHcoCBxbOpXVpDx EgLt7BKPrh1jAUmwCAhIfJt8iAXiHlm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ZTWe8vL8dunj2GY+qyzv3 9Sd2By5QkY4+Vh156NaMm4nXn2X723c/OxPBtFvu/soS/XnbTvTJr0isnXy0QJ2nsu3Vndx5 94uyL0c6mK/rWlyz8MqqtR7vbimxFGckGmoxFxUnAgCapFcAzAIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQkFO7bfoPoNJucekGXq3FPzr+K+RC0MMUu7INs200jhr4EFdPpJ9C/4Jm8xvBvRQhjK4UOV X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Accessing SPI registers is slow, but access to the FIFO level register in particular seems to be extraordinarily expensive (I measure up to 600ns). Perhaps it is required to synchronise with the SPI byte output logic which might run at 1/8th of the 40MHz SPI speed (just a guess). Reduce access to this register by filling up and emptying FIFOs more completely, rather than just one word each time around the inner loop. Since the rxfifo value will now likely be much greater that what we read before we fill the txfifo, we only fill the txfifo halfway. This is because if the txfifo is empty, but the rxfifo has data in it, then writing too much data to the txfifo may overflow the rxfifo as data arrives. This speeds up SPI flash reading from about 1MB/s to about 2MB/s on snow. Based on "[PATCH 0/2 V3] exynos: Support a delay after deactivate for SPI" Signed-off-by: Simon Glass Signed-off-by: Rajeshwari Shinde --- Changes in V2: - Rebased on "[PATCH 0/2 V5] spi: Enable SPI_PREAMBLE Mode" drivers/spi/exynos_spi.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index deb32bd..bcca3d6 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -259,24 +259,27 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, /* Keep the fifos full/empty. */ spi_get_fifo_levels(regs, &rx_lvl, &tx_lvl); - if (tx_lvl < spi_slave->fifo_size && out_bytes) { + while (tx_lvl < spi_slave->fifo_size/2 && out_bytes) { temp = txp ? *txp++ : 0xff; writel(temp, ®s->tx_data); out_bytes--; + tx_lvl++; } if (rx_lvl > 0) { - temp = readl(®s->rx_data); - if (spi_slave->skip_preamble) { - if (temp == SPI_PREAMBLE_END_BYTE) { - spi_slave->skip_preamble = 0; - stopping = 0; + while (rx_lvl > 0) { + temp = readl(®s->rx_data); + if (spi_slave->skip_preamble) { + if (temp == SPI_PREAMBLE_END_BYTE) { + spi_slave->skip_preamble = 0; + stopping = 0; + } + } else { + if (rxp || stopping) + *rxp++ = temp; + in_bytes--; } - } else { - if (rxp || stopping) - *rxp++ = temp; - in_bytes--; - } - toread--; + toread--; + rx_lvl--; } else if (!toread) { /* * We have run out of input data, but haven't read