[PATCH 10/10] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs
Jan Lübbe
jlu at pengutronix.de
Wed Sep 5 05:20:51 EDT 2012
Hi,
On Tue, 2012-09-04 at 10:58 +0200, Sascha Hauer wrote:
> > + for (i = 0; i < len; i++) {
> > + /* wait till TX register is empty (TXS == 1) */
> > + while
> (!(readl(®s->channel[spi->chip_select].chstat) &
> > + OMAP3_MCSPI_CHSTAT_TXS)) {
> > + if (--timeout <= 0) {
> > + printf("SPI TXS timed out, status=0x%
> 08x\n",
> > +
> readl(®s->channel[spi->chip_select].chstat));
> > + return -1;
> > + }
> > + }
>
> Please use a well defined timeout rather than 'poll a million times'
I tried using is_timeout like this:
timer_start = get_time_ns();
while (!(readl(®s->channel[spi->chip_select].chstat) &
OMAP3_MCSPI_CHSTAT_TXS)) {
if (is_timeout(timer_start, SPI_WAIT_TIMEOUT)) {
printf("SPI TXS timed out, status=0x%08x\n",
readl(®s->channel[spi->chip_select].chstat));
return -1;
}
}
With SPI_WAIT_TIMEOUT = MSECOND this results in ~23% more time needed
for reading/writing:
With a simple counter:
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12659ms
With is_timeout():
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15561ms
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15564ms
barebox at KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15568ms
Is this really acceptable? Is there a way to avoid the overhead of
calling several functions for each loop?
Regards,
Jan
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list