spi: mpc512x: improve throughput in the RX/TX func
authorGerhard Sittig <gsi@denx.de>
Mon, 3 Jun 2013 12:03:50 +0000 (14:03 +0200)
committerMark Brown <broonie@linaro.org>
Tue, 4 Jun 2013 17:22:47 +0000 (18:22 +0100)
commit5df24ea63d1eb1b3b0556817bdaf378c19f196ea
treec747df0a3d7ee7cd8f78ddecb01776a946fda64e
parentc36e93a0bdc7df31543a6950454dbd26b56c9015
spi: mpc512x: improve throughput in the RX/TX func

change the MPC512x SPI controller's transmission routine to increase
throughput: allow the RX byte counter to "lag behind" the TX byte
counter while iterating over the transfer's data, only wait for the
remaining RX bytes at the very end of the transfer

this approach eliminates delays in the milliseconds range, transfer
times for e.g. 16MB of SPI flash data dropped from 31s to 9s, correct
operation was tested by continuously transferring and comparing data
from an SPI flash (more than 200GB in some 45 hours)

background information on the motivation:

one might assume that all the RX data should have been received when the
TX data was sent, given the fact that we are the SPI master and provide
all of the clock, but in practise there's a difference

the ISR is triggered when the TX FIFO became empty, while transmission
of the last item still occurs (from the TX hold and shift registers),
sampling RX data on the opposite clock edge compared to the TX data adds
another delay (half a bit period), and RX data needs to propagate from
the reception buffer to the RX FIFO depending on the specific SoC
implementation

to cut it short: a difference between TX and RX byte counters during
transmission is not just acceptable but should be considered the regular
case, only the very end of the transfer needs to make sure that all of
the RX data was received before deasserting the chip select and telling
the caller that transmission has completed

Signed-off-by: Gerhard Sittig <gsi@denx.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-mpc512x-psc.c
This page took 0.026129 seconds and 5 git commands to generate.