Re: [PATCH/RFC] SPI: add DMAUNSAFE analog to David Brownell's core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Brownell wrote:

On Wednesday 14 December 2005 5:50 am, Vitaly Wool wrote:
It's way better to just insist that all I/O buffers (in all
generic APIs) be DMA-safe.  AFAICT that's a pretty standard
rule everywhere in Linux.
I agree.
Well, why then David doesn't insist on that in his own code?
His synchronous transfer functions

are allocating transfer buffers on stack which is not DMA-safe.

I think the very first version did that, but nothing since
has taken that shortcut.  (Several months now.)  It uses
a buffer that's allocated on the heap.
You're wrong.
Isn't it a part of your code:

static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
{
       ssize_t                 status;
       u8                      result;

       status = spi_write_then_read(spi, &cmd, 1, &result, 1);

       /* return negative errno or unsigned value */
       return (status < 0) ? status : result;
}

You're allocating u8 var on stack, then allocate a 1-byte-long buffer and copy the data instead of letting the controller driver decide whether this allocation/copy is necessary or not. And in 99% cases it's not gonna be necessary as any controller driver w/o brain damage will transfer this as PIO. So the overhead for sending/receiving 1 byte will be _very big_ (trylock, kmalloc, memcpy). See now what I'm talking about?


Then he starts messing with allocate-or-use-preallocated stuff etc. etc.
Why isn't he just kmalloc'ing/kfree'ing buffers each time these functions are called

So that the typical case, with little SPI contention, doesn't
hit the heap?  That's sure what I thought ... though I can't speak
for what other people may think I thought.  You were the one that
wanted to optimize the atypical case to remove a blocking path!
I meant kmalloc'ing/kfree'ing buffers is spi_w8r8/spi_w8r16/etc.

Vitaly
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux