2008-06-30 13:51:22

by Oliver Neukum

[permalink] [raw]
Subject: Re: usb_get_status(): what a weird implementation !

Am Montag 30 Juni 2008 14:41:37 schrieb Francis Moreau:
> On Mon, Jun 30, 2008 at 1:46 PM, Oliver Neukum <[email protected]> wrote:
> > Am Montag 30 Juni 2008 13:04:21 schrieb Francis Moreau:

> >> well, it wouldn't be hard to allocated a buf on the stack with correct
> >> alignement
> >> and size for DMA mapping.
> >
> > Where would you put it and meet the alignment requirements?
> >
>
> wouldn't this code below do the trick ?
>
> void foo(void)
> {
> unsigned char __buf[2 * CACHE_LINE_SIZE];
> unsigned char *buf;
>
> buf = ((unsigned long)__buf) + CACHE_LINE_SIZE-1) & ~(CACHE_LINE_SIZE-1);
> }
>
> but I agree it looks hackish.

If your buffer is smaller than CACHE_LINE_SIZE it should work.
However, this needs input from people who understand DMA in and out.
But how large is 2 * CACHE_LINE_SIZE compared to the kernel stack?

Regards
Oliver


2008-06-30 14:04:08

by Francis Moreau

[permalink] [raw]
Subject: Re: usb_get_status(): what a weird implementation !

On Mon, Jun 30, 2008 at 3:51 PM, Oliver Neukum <[email protected]> wrote:
>
> If your buffer is smaller than CACHE_LINE_SIZE it should work.
> However, this needs input from people who understand DMA in and out.

yeah, that's the reason why it's a hack.

Maybe adding a new helper in the dma API would be better...

> But how large is 2 * CACHE_LINE_SIZE compared to the kernel stack?

CACHE_LINE_SIZE = 32 bytes is common for embedded systems I guess.
For big system, I dunno.

Kernel stack size is usually 4KiB.

--
Francis

2008-06-30 14:11:23

by Oliver Neukum

[permalink] [raw]
Subject: Re: usb_get_status(): what a weird implementation !

Am Montag 30 Juni 2008 16:03:52 schrieb Francis Moreau:
> On Mon, Jun 30, 2008 at 3:51 PM, Oliver Neukum <[email protected]> wrote:
> >
> > If your buffer is smaller than CACHE_LINE_SIZE it should work.
> > However, this needs input from people who understand DMA in and out.
>
> yeah, that's the reason why it's a hack.
>
> Maybe adding a new helper in the dma API would be better...
>
> > But how large is 2 * CACHE_LINE_SIZE compared to the kernel stack?
>
> CACHE_LINE_SIZE = 32 bytes is common for embedded systems I guess.
> For big system, I dunno.
>
> Kernel stack size is usually 4KiB.
>

Well, we have:
asm-mips/mach-ip32/kmalloc.h:#define ARCH_KMALLOC_MINALIGN 128
That's 256 bytes, that is 1/16 of the stack.

Regards
Oliver

2008-06-30 14:22:34

by Francis Moreau

[permalink] [raw]
Subject: Re: usb_get_status(): what a weird implementation !

On Mon, Jun 30, 2008 at 4:11 PM, Oliver Neukum <[email protected]> wrote:
>
> Well, we have:
> asm-mips/mach-ip32/kmalloc.h:#define ARCH_KMALLOC_MINALIGN 128
> That's 256 bytes, that is 1/16 of the stack.

yep but I wouldn't call such beast an embedded system ;)

And on this system stack size is 8 KiB.

But I agree a plain stack allocation as I showed is not usable.

--
Francis