[U-Boot] [PATCH] mmc:dcache: Cache line size aligned internal MMC buffers

Anton Staaf robotboy at google.com
Tue Aug 23 22:27:26 CEST 2011


On Tue, Aug 23, 2011 at 1:12 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Anton Staaf,
>
> In message <CAF6FioXeFQP2a0VaZOVOTmxPvJxF4=kamS18=2=p6TFNefwUuA at mail.gmail.com> you wrote:
>>
>> > what about adding a new func like:
>> > #define dma_buffer_alloca(size)
>>
>> I generally avoid large allocations on the stack, they can confuse
>> virtual stack management and blow out small embedded stacks.  But
>> neither of these are really a problem for most U-Boot targets.  Are
>> you thinking something like:
>>
>> #define dma_buffer_alloca(size) alloca(size + get_dcache_line_size() -
>> 1) & ~(get_dcache_line_size() - 1);
>
> I don't think I will accept any alloca() based code into mainline.

Ahh, that must have been my reason for not using it in the first
place, a premonition.  :)

So then, to guide our efforts, what is a more suitable solution?
Would you prefer we stick with the existing path of calling memalign
and passing it the cache size by directly calling
get_dcache_line_size?  Or would you prefer something more like a
dma_buffer_malloc function that allocates on the heap a cache line
size aligned buffer and returns it?

Hmm, that will require a bit of thought because we need to recover the
original pointer returned by malloc to cleanly free the buffer later.

Thanks,
    Anton

> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "There are three principal ways to lose money: wine, women,  and  en-
> gineers.  While  the first two are more pleasant, the third is by far
> the more certain."                      -- Baron Rothschild, ca. 1800
>


More information about the U-Boot mailing list