linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Guy <martinwguy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Mika Westerberg <mika.westerberg-X3B1VOXEql0@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v3 1/2] spi: implemented driver for Cirrus EP93xx SPI controller
Date: Mon, 19 Apr 2010 20:16:51 +0100	[thread overview]
Message-ID: <y2q56d259a01004191216o48763eafy6401779ddae0f1@mail.gmail.com> (raw)
In-Reply-To: <q2pfa686aa41004191102qc93f09b6m941785b4cb4e32db-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 4/19/10, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
>  >> > +       /* read all received data */
>  >> > +       while ((ep93xx_spi_read_u8(espi, SSPSR) & SSPSR_RNE) &&
>  >> > +               espi->rx < t->len) {
>  >> > +               ep93xx_do_read(espi, t);
>  >> > +               espi->fifo_level--;
>  >> > +       }
>  >>
>  >> Another busywait loop.  Could end up burning an awful lot of cycles
>  >> here.  A state machine might be more suitable for this driver so that
>  >> processing can be punted to deferred work when the FIFO gets either
>  >> empty or full.
>  >
>  > FIFO size is max 8 frames so there should be 8 iterations when the
>  > FIFO is full. So is it enought to to add check that we only read
>  > max 8 frames from the FIFO?
>
>  If you do it right, FIFO size shouldn't matter.  The driver should
>  easily be able to read however many are available and defer until more
>  is ready.

Sorry, I completely missed the point at the end of the last post.

This is not a busywait loop. It takes bytes out of the RX FIFO until
it is empty, which is all useful work. There is also no way to tell
just from our internal variables how many bytes are in the RX FIFO as
far as I know, so the only way is to check the Receiver-Not-Empty
status bit (which is what this code does).

However, the
>  >> > +               espi->rx < t->len) {
is redundant, since it will always be true when the first condition is
true, though the compiler cannot see optimise it out.

If you're afraid that a caller might pass the driver a receive buffer
shorter than than the transmit buffer, it would be better to check
that once when the transfer is requested, not once per byte received!

The same goes for the other checks for conditions that can only ever
be true or only ever false that I mentioned in my remarks on earlier
patches, and other optimizations. We are at the byte-per-byte level of
a device driver for a slow CPU, where efficiency is at a premium.

     M

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

  parent reply	other threads:[~2010-04-19 19:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 14:10 [PATCH v3 0/2] spi: driver for Cirrus EP93xx SPI controller Mika Westerberg
     [not found] ` <cover.1271156934.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-13 14:10   ` [PATCH v3 1/2] spi: implemented " Mika Westerberg
2010-04-17  6:30     ` Grant Likely
2010-04-17 11:00       ` Mika Westerberg
2010-04-19 18:02         ` Grant Likely
     [not found]           ` <q2pfa686aa41004191102qc93f09b6m941785b4cb4e32db-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-19 18:52             ` Martin Guy
     [not found]               ` <o2g56d259a01004191152w9c2245fdgaa2d4ac1b9e95ed7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-19 19:05                 ` Grant Likely
     [not found]                   ` <j2hfa686aa41004191205jf61e53ectc994ab0e5a2c4c53-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-19 19:26                     ` Martin Guy
2010-04-19 19:16             ` Martin Guy [this message]
2010-05-20  4:56               ` Grant Likely
2010-04-20  6:16             ` Mika Westerberg
     [not found]   ` <e0e5dc30af89f0b65fd2e5e52f9e7fe9f162516b.1271156934.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-13 14:10     ` [PATCH v3 2/2] ep93xx: SPI driver platform support code Mika Westerberg
     [not found]       ` <d24cf3f10fb125837c9b660b3880956940440b79.1271156934.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-16 18:40         ` H Hartley Sweeten
2010-04-16 18:28   ` [PATCH v3 0/2] spi: driver for Cirrus EP93xx SPI controller H Hartley Sweeten
     [not found]     ` <0D753D10438DA54287A00B0270842697636D710785-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-17  4:59       ` Mika Westerberg
     [not found]         ` <20100417045913.GA19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-17 18:43           ` Martin Guy
     [not found]             ` <s2i56d259a01004171143m74b06d85yd1cbb38ef7ce778e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-18  5:33               ` Mika Westerberg
2010-04-19 17:04           ` H Hartley Sweeten
     [not found]             ` <0D753D10438DA54287A00B0270842697636D78D9CF-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-19 17:44               ` Mika Westerberg
     [not found]                 ` <20100419174446.GH19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-19 18:11                   ` H Hartley Sweeten

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=y2q56d259a01004191216o48763eafy6401779ddae0f1@mail.gmail.com \
    --to=martinwguy-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mika.westerberg-X3B1VOXEql0@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).