public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Vitaly Wool <vwool@ru.mvista.com>
Cc: linux-kernel@vger.kernel.org, dpervushin@gmail.com,
	akpm@osdl.org, greg@kroah.com, basicmark@yahoo.com,
	komal_shah802003@yahoo.com, stephen@streetfiresound.com,
	spi-devel-general@lists.sourceforge.net, Joachim_Jaeger@digi.com
Subject: Re: [PATCH 2.6-git] MTD/SPI dataflash driver
Date: Fri, 2 Dec 2005 14:07:18 -0800	[thread overview]
Message-ID: <200512021407.18816.david-b@pacbell.net> (raw)
In-Reply-To: <438FE350.1010106@ru.mvista.com>


> However, it would be nice if someone compared the performance of both 
> variants.

> >     * original code could be implemented in a single DMA chain on
> >      at least two systems I happen to have handy ... one IRQ.
> >
> >    * this version requires two separate chains, with an intervening
> >      task schedule.  (More than twice the cost.)

They differ by at least the cost of an extra IRQ and task schedule, so
the performance delta would be load-dependant.  In a real-time setup
where that task was given time slices at fixed intervals, that might
mean the two-request version takes twice as long.  ;)



> Whoops. Lemme express my thoughts here.
> First, the DMA controller that can handle chained requests which are 
> working with different devices (i.e. write then read does that - first 
> mem2per, then per2mem) are *very* rare thing.

The way they usually work is allocate two DMA channels to the device,
one for read and one for write.  The controllers just makes sure there's
one byte read for every one written, and the DMA channels just stream
along with them.  (Possibly one channel talks to a bitbucket.)

AT91, OMAP, and PXA hardware all claim hardware support sufficient to
do that.  (Errata aside.)  That's not even rare hardware, much less
"very rare"; they're stocked at DigiKey, ready to throw into boards.


> > - Chipselect works differently in your code.  You're giving one
> >   driver control over all the devices sharing a controller, by
> >   blocking requests going to other devices until your driver yields
> >   the chipselect.  
> >  
> >
> The controllers we were working with are _not_ able to handle 
> simultaneous requests to different devices on the same bus.

Of course not; SPI doesn't work that way.  But my point was that your
changes show a controller driver that's clearly required to "lock" the
bus, through that chipselect, between requests ... which is not only
antithetical to the "requests are asynchronous" model that had earlier
been agreed on, but also creates problems of its own:

> >  		This seems like a bad idea even if you ignore
> > how it produces priority inversions in your framework.  :)

So consider two different tasks accessing devices on the same SPI bus.

One is lower priority, currently waiting for an SPI request to complete.
A request that has your magic "leave me owning chipselect/bus after
this request flag" ... because the first thing it's going to do when
it returns is start another transfer.  (And in the case of the MTD driver,
that transfer could already have been queued, removing the issue as
well as the need for that flag.)

Now the high priority task issues a request to the other device on
that same SPI bus.  This means that *two* other tasks ought to be
temporarily operating with that higher priority:  whatever task
you've allocated to manage the I/O queue on that bus (plus maybe
an IRQ task with RT_PREEMPT); and the task that's waiting for that
transfer to complete.  Inversions ... 

- Dave

  reply	other threads:[~2005-12-02 22:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-01 16:11 [PATCH 2.6-git] SPI core refresh Vitaly Wool
2005-12-01 16:18 ` [PATCH 2.6-git] MTD/SPI dataflash driver Vitaly Wool
2005-12-01 18:33   ` David Brownell
2005-12-02  6:01     ` Vitaly Wool
2005-12-02 22:07       ` David Brownell [this message]
2005-12-01 16:21 ` [PATCH 2.6-git] SPI core refresh Russell King
2005-12-01 16:30   ` Vitaly Wool
2005-12-01 18:04 ` Stephen Street
2005-12-01 18:22 ` Greg KH
2005-12-02  6:06   ` Vitaly Wool
2005-12-02 18:50     ` Mark Underwood
2005-12-02 20:13     ` Greg KH
2005-12-05 18:01 ` Vitaly Wool
2005-12-08  1:59   ` David Brownell
2005-12-08  6:33     ` Vitaly Wool
2005-12-09 22:55       ` David Brownell
2005-12-10 11:15         ` Vitaly Wool
2005-12-11 12:36         ` Vitaly Wool
2005-12-11 17:03           ` [spi-devel-general] " Vitaly Wool
2005-12-11 20:17             ` David Brownell
2005-12-11 22:13               ` Vitaly Wool
2005-12-11 23:54                 ` David Brownell
2005-12-12  7:09                   ` Vitaly Wool
2005-12-11 22:15               ` Vitaly Wool
2005-12-11 22:18               ` Vitaly Wool
  -- strict thread matches above, loose matches on Subject: below --
2005-12-03 11:32 [PATCH 2.6-git] MTD/SPI dataflash driver vitalhome

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=200512021407.18816.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=Joachim_Jaeger@digi.com \
    --cc=akpm@osdl.org \
    --cc=basicmark@yahoo.com \
    --cc=dpervushin@gmail.com \
    --cc=greg@kroah.com \
    --cc=komal_shah802003@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    --cc=stephen@streetfiresound.com \
    --cc=vwool@ru.mvista.com \
    /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