From patchwork Tue Oct 8 10:50:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 20891 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B4DD125C6D for ; Tue, 8 Oct 2013 10:48:44 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id u18sf16179571qcx.10 for ; Tue, 08 Oct 2013 03:48:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:dlp-filter:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=dzwhGnUU7FM7IH+fbq5zsg11eHCrh/UarfNkWjgCMXQ=; b=lW51byKubYm5dKphBlYeHJ8rQ0mqrPaqG1KNb0R+rzBPwk+ZKvVQb61JoXQ9lho+Mj 3bmxRSQVW7gmo4iGgQTVcg5Fczy0UxZN8fScSZ95dJGo1tVVV186iXxVJeKsyjaG1JoC WBaTKjSn79kgZ06zwZQ2Q4yl+oKdqMG571i8UOAPEX/WUp1I66dusPjgYOsifoGqF5vW 7EDUJ6hTQLhaWfnxDL0LwynM3LKe8R2N87BsMUb21b/g5UjJQRiNtQc1GuyhRwyrSNJd esR84mtoXdLXU+edygCSoC5ibalsls1QdaUs5ndrsP3dOxyhtXevHKZFPDHebZM0fcdz YEZw== X-Received: by 10.236.54.68 with SMTP id h44mr888547yhc.21.1381229324590; Tue, 08 Oct 2013 03:48:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.170 with SMTP id z10ls150455qej.32.gmail; Tue, 08 Oct 2013 03:48:44 -0700 (PDT) X-Received: by 10.52.170.111 with SMTP id al15mr111701vdc.43.1381229324488; Tue, 08 Oct 2013 03:48:44 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id bq2si9260927vcb.115.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Oct 2013 03:48:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id e15so4047307vbg.18 for ; Tue, 08 Oct 2013 03:48:44 -0700 (PDT) X-Gm-Message-State: ALoCoQlPLunL190dQnWMxZgs+VAiFKWQ4E3kagcvS/XVFOuWSpkMiWlsXC4zPHn0sJZ/q7f0+KMi X-Received: by 10.52.64.235 with SMTP id r11mr86343vds.49.1381229324402; Tue, 08 Oct 2013 03:48: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.174.196 with SMTP id u4csp194483vcz; Tue, 8 Oct 2013 03:48:43 -0700 (PDT) X-Received: by 10.68.113.99 with SMTP id ix3mr1105024pbb.180.1381229323320; Tue, 08 Oct 2013 03:48:43 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id ar2si26054370pbc.22.1969.12.31.16.00.00; Tue, 08 Oct 2013 03:48:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MUC00AHSJCFX9N0@mailout2.samsung.com>; Tue, 08 Oct 2013 19:48:42 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.125]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id F4.99.29948.903E3525; Tue, 08 Oct 2013 19:48:41 +0900 (KST) X-AuditID: cbfee691-b7f4a6d0000074fc-30-5253e3098008 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A7.FA.05832.903E3525; Tue, 08 Oct 2013 19:48:41 +0900 (KST) Received: from localhost.localdomain.com ([107.108.73.95]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MUC00059JCVG700@mmp1.samsung.com>; Tue, 08 Oct 2013 19:48:41 +0900 (KST) From: Rajeshwari S Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, u-boot-review@google.com, jagannadh.teki@gmail.com, alim.akhtar@samsung.com Subject: [PATCH 3/4] spi: exynos: Minimise access to SPI FIFO level Date: Tue, 08 Oct 2013 16:20:05 +0530 Message-id: <1381229406-12478-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.11.7 In-reply-to: <1381229406-12478-1-git-send-email-rajeshwari.s@samsung.com> References: <1381229406-12478-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRmVeSWpSXmKPExsWyRsSkVpfzcXCQwc/tNhYP5m1js3i4/iaL xa6tLawWHUdaGC2mHP7CYvFtyzZGi+WvN7JbvN3bye7A4TG74SKLx85Zd9k9Fmwq9bhzbQ+b x9k7Oxg9+rasYgxgi+KySUnNySxLLdK3S+DK2PbjJ2PBXKGKvy+uszcw/uftYuTgkBAwkdjZ EdbFyAlkiklcuLeeDcQWEljKKPHgYiJE3ERiz9W1rBDxRYwSixcXdTFyAdldTBKXpjxiAp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VeHgFDgcFCbEmlhVX5h5ilOBgVhLhDbwfHCTE m5JYWZValB9fVJqTWnyIMRnoqInMUqLJ+cCIzyuJNzQ2MTc1NrU0sTAxsyRNWEmc92CrdaCQ QHpiSWp2ampBahHMFiYOTqkGxtzjEzwPCPBsWVew3UpqRqRCYae/6bq8bS/TI7OsUt4ubHqX 7pLi5CfEULdi1o2PwvM43y4vVfGwj1/hLRXOtNPv9fEJq2+8e7vyL2Pshj0HY4wP5q20sZ+o 8b5YyNSfyW3yz8ePGTwmK852KHq77PiqrEsOS/4t7G1bcaLPaarG4kkzTretNFRiKc5INNRi LipOBAAPJmty7gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 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. Signed-off-by: Simon Glass Signed-off-by: Rajeshwari S Shinde --- drivers/spi/exynos_spi.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index d7fdaac..7407d6c 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -247,24 +247,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