From: Martin Guy <martinwguy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: H Hartley Sweeten
<hartleys-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
Cc: "spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
Mika Westerberg <mika.westerberg-X3B1VOXEql0@public.gmane.org>,
"ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org"
<ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v4 1/2] spi: implemented driver for Cirrus EP93xx SPI controller
Date: Thu, 22 Apr 2010 21:19:32 +0100 [thread overview]
Message-ID: <x2w56d259a01004221319y27d25d30sbe8b548c4d7932fd@mail.gmail.com> (raw)
In-Reply-To: <0D753D10438DA54287A00B0270842697636D940C95-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
On 4/22/10, H Hartley Sweeten <hartleys-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org> wrote:
> > Further, on a suspicion about the silliness of the per-transfer
> > bits_per_word being checked right down the bottom of the lowest lever
> > byte-read/writing routine instead of once per transfer, I split
> > ep93xx_spi_read and _write into 8 and 16-bit variants, and checked
> > t->bits_per_word once outside the read and write loops.
> >
> > This gives:
> > 60.0% 59.3% 285906 irq/MB
>
>
> It looks like splitting the 8/16-bit read/write routines does help
> with cpu usage compared to the tests above. Was the data transfer
> (kB/sec) any better?
No, exactly the same.
>From a code poin tof view, one of the routines is just
if (bits > 8) {
this16
} else {
that8
}
so no loss in splitting it. You need two copies of the read and write
loops in the read_write routine, though it's only 8 extra lines of
code for a 1% CPU increase.
I don't have strong feelings about this it way.
> Yes. Too bad we can't also combine multiple messages that might be in
> the queue...
I wonder if it might be easier, if there are several parts to a
message, to just cook up one big new transfer, copy the data into it
and just do that. It would mean copying every data block of course
since in the MMC/SD case they are 512+2+1.
> But, if this gets to complicated it might not be worth holding off
> getting it merged
Possibly. It depends on the timing of the merge windows. The current
code works with some devices.
> > It now occurs to me that another step in CPU efficiency could be had
> > by abusing the receive-fifo-is-half-full interrupt to signal the
> > completion of a transfer. This would only work for transfers of four
> > or more words and would need some careful jiggery-pokery at end of
> > transfer to turn the tx-fifo-is-half-empty interrupt enable off and
> > ensure that exactly four words would end up in the RX FIFO.
>
> That might work but I think it could break horribly. The "jiggery-pokery"
> could end up being pretty messy.
Yes. It is looking nasty and it would make a mess of the place where
the continuity stuff needs to happen to achieve actual functionality
improvements.
To get some idea of the potential wins I've been instrumenting the
code today to see how many interrupts it takes to receive the last 4
words
At 3.7MHz I'm seeing up to 3 interrupts waiting for the final draining
to happen, with an average of 1.36 (1 would be the perfect figure)
At 400kHz it takes up to 26 with an average of 9.92
Me, I only really care about the SD card case, where a half dozen
useless interrupts per 512-byte block is not going to impact on the
CPU usage much. In fact, by making the interrupt routine more complex
it may even end up being more cpu hungry in the end.
On the other hand, slow clock-speed devices are using needless high
CPU, especially if the transfer sizes are small as is typical with
command-response devices.
> But, the tx-fifo-is-half-empty might be what is needed to handle the
> multiple transfer merging. We know the driver is finished transfering
> the data to the fifo when (espi->tx == t->len). At this point we are
> just wating for the last (fifo_level) bytes to come in on the rx fifo,
> this could be anything from 1 to 8 bytes.
Another instrumentation show that yes, at 3.7MHz, the data read on
each interrupt is between 1 and 8 words. I'm surprised it gets to 8
full - maybe when the interrupt is requested while some other IRQ
(ether? clock tick?) is already in progress? I'm instrumenting in a
way that shouldn't change the timing characteristics of the transfer
(ie a tiny printk's only after end of transfer)
> > It's a horrible thought, and I suspect that the DMA engine is the real answer.
>
> The DMA engine might help but it's not here yet....
Yes. What I mean is that the prospect of that happening somewhere in
the future reduces the importance of doing hairy jiggery pokery with
the interrupt version.
M
------------------------------------------------------------------------------
next prev parent reply other threads:[~2010-04-22 20:19 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 15:11 [PATCH v4 0/2] spi: driver for Cirrus EP93xx SPI controller Mika Westerberg
[not found] ` <cover.1271774845.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-20 15:11 ` [PATCH v4 1/2] spi: implemented " Mika Westerberg
[not found] ` <e96939d18bcbfb7a28ba4a925d7788884566db8c.1271774845.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-20 17:24 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D7F4E7F-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-21 7:16 ` Mika Westerberg
[not found] ` <20100421071629.GL19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-21 16:47 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D8C84DA-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-21 16:54 ` Mika Westerberg
[not found] ` <20100421165420.GP19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-22 2:47 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D8C8CDD-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-22 5:53 ` Mika Westerberg
2010-04-22 14:11 ` Martin Guy
2010-04-22 14:28 ` Martin Guy
[not found] ` <x2g56d259a01004220728i7f07d492t4c4f63e0ef2e38d9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-22 17:39 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D940C95-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-22 20:19 ` Martin Guy [this message]
2010-04-20 22:16 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D85BCCC-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-20 23:54 ` Martin Guy
[not found] ` <z2h56d259a01004201654y93f6c533j11b5accd7e2f46e7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-21 0:11 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D85BDD8-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-21 0:43 ` H Hartley Sweeten
2010-04-21 1:10 ` Martin Guy
[not found] ` <n2u56d259a01004201810j22c17bcfn9fee59e9c65c4d7f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-21 1:52 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D85BE26-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-21 7:00 ` Mika Westerberg
2010-04-21 10:46 ` Mika Westerberg
[not found] ` <20100421104651.GO19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-21 18:00 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D8C8672-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-22 5:45 ` Mika Westerberg
[not found] ` <20100422054519.GA26418-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-22 21:29 ` Ryan Mallon
2010-04-22 17:55 ` Mika Westerberg
2010-04-22 20:43 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D9410F0-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-23 5:20 ` Mika Westerberg
[not found] ` <20100423052003.GF26418-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-23 17:24 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D9419BC-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-23 23:01 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D9B794A-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-25 9:29 ` Martin Guy
[not found] ` <y2x56d259a01004250229he9cb2ee3pf69669c9226f80fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-25 9:38 ` Martin Guy
[not found] ` <m2l56d259a01004250238s99d6c869s1ee084b36f9736a0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-25 20:25 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D9B7E66-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-26 10:02 ` Mika Westerberg
[not found] ` <20100426100258.GG26418-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-26 16:54 ` H Hartley Sweeten
2010-04-26 10:09 ` Mika Westerberg
2010-04-26 14:35 ` Martin Guy
[not found] ` <k2l56d259a01004260735nb44e9dddy5b08668787070ac7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-26 17:05 ` H Hartley Sweeten
2010-04-21 6:37 ` Mika Westerberg
[not found] ` <20100421063712.GJ19534-WfG2TfFPcQ9S6P4I59wummXnswh1EIUO@public.gmane.org>
2010-04-21 17:08 ` H Hartley Sweeten
2010-04-24 18:14 ` Martin Guy
[not found] ` <p2h56d259a01004241114qb1b1815em9657e5a857a9d4ee-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-04-25 19:55 ` H Hartley Sweeten
[not found] ` <0D753D10438DA54287A00B0270842697636D9B7E4F-gaq956PjLg32KbjnnMDalRurcAul1UnsRrxOEX5GOmysTnJN9+BGXg@public.gmane.org>
2010-04-26 10:34 ` Mika Westerberg
2010-04-26 12:58 ` Martin Guy
2010-04-20 15:11 ` [PATCH v4 2/2] ep93xx: SPI driver platform support code Mika Westerberg
[not found] ` <509a89ad62001de9de23129b4c34148aef28ef19.1271774845.git.mika.westerberg-X3B1VOXEql0@public.gmane.org>
2010-04-20 16:35 ` 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=x2w56d259a01004221319y27d25d30sbe8b548c4d7932fd@mail.gmail.com \
--to=martinwguy-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=hartleys-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=mika.westerberg-X3B1VOXEql0@public.gmane.org \
--cc=ryan-7Wk5F4Od5/oYd5yxfr4S2w@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).