mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Jan Lübbe" <jlu@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox-request <barebox@lists.infradead.org>
Subject: Re: [PATCH 10/10] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs
Date: Wed, 05 Sep 2012 11:20:51 +0200	[thread overview]
Message-ID: <1346836851.3388.6.camel@coredoba.hi.pengutronix.de> (raw)
In-Reply-To: <20120904085858.GT26594@pengutronix.de>

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(&regs->channel[spi->chip_select].chstat) &
> > +                      OMAP3_MCSPI_CHSTAT_TXS)) {
> > +                     if (--timeout <= 0) {
> > +                             printf("SPI TXS timed out, status=0x%
> 08x\n",
> > +
> readl(&regs->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(&regs->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(&regs->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@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12659ms

With is_timeout():
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15561ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15564ms
barebox@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 |


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2012-09-05  9:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 11:45 Prepare support for TI AM35xx Jan Luebbe
2012-09-03 11:45 ` [PATCH 01/10] drivers/nor/m25p80: add JEDEC ID for Micron/Numonyx SPI NOR flash Jan Luebbe
2012-09-03 11:45 ` [PATCH 02/10] drivers/nor/m25p80: add MEMGETINFO ioctl Jan Luebbe
2012-09-04  8:20   ` Sascha Hauer
2012-09-03 11:45 ` [PATCH 03/10] Makefile: add target to produce a SPL compatible uimage Jan Luebbe
2012-09-03 16:22   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-03 11:45 ` [PATCH 04/10] scripts: add tool to create image for SPI boot on AM35xx Jan Luebbe
2012-09-04  8:27   ` Sascha Hauer
2012-09-03 11:46 ` [PATCH 05/10] common: split out meminfo output and make it optional Jan Luebbe
2012-09-03 11:46 ` [PATCH 06/10] omap: add SPI as a boot mode for xload Jan Luebbe
2012-09-03 16:24   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-04  7:41     ` Jan Weitzel
2012-09-03 11:46 ` [PATCH 07/10] drivers/net/ksz8864rmn: add driver for Micrel KSZ8864RMN Ethernet Switch Jan Luebbe
2012-09-03 11:46 ` [PATCH 08/10] drivers/net: add driver for the EMAC device found in some TI SoCs Jan Luebbe
2012-09-03 16:27   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-04  8:42   ` Sascha Hauer
2012-09-03 11:46 ` [PATCH 09/10] omap3: allow enabling clocks for UART3, MMC1 and SPI Jan Luebbe
2012-09-04  8:48   ` Sascha Hauer
2012-09-05  9:28     ` Jan Lübbe
2012-09-03 11:46 ` [PATCH 10/10] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs Jan Luebbe
2012-09-03 16:32   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-04  8:58   ` Sascha Hauer
2012-09-05  9:20     ` Jan Lübbe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346836851.3388.6.camel@coredoba.hi.pengutronix.de \
    --to=jlu@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox