[U-Boot] [PATCH] mmc:dcache: Cache line size aligned internal MMC buffers
Lukasz Majewski
l.majewski at samsung.com
Wed Aug 24 16:31:37 CEST 2011
Hi Wolfgang,
> I think I'd like to see a macro that can be used like this:
>
> void *dma_buffer_pointer = DMA_BUFFER(size_in_bytes);
>
Frankly speaking I don't know any easy way to define buffer this way
in a macro (at least without digging deep enough to C preprocessor
programming tricks). Maybe Mike or Anton knows.
The void *dma_buffer_pointer = DMA_BUFFER(size_in_bytes); approach
needs to do following things in macro:
#define DMA_BUFFER(100) \
char buf[100 + get_dcache_line_size]; \
unsigned long tmp = (unsigned long) buf; \
void* buf_out = (void*) ((tmp + (get_dcache_line_size() - 1)) &
~(get_dcache_line_size() - 1))
The problem here is to assign the buf_out pointer to the void
*dma_buffer_pointer. How can we "return" the void *buf_out?
For comparison please look to this solution:
#define ALIGN_ADDR(addr) ((void *)(((unsigned long) addr +
get_dcache_line_size() - 1)\ & ~(get_dcache_line_size() - 1)))
#define DMA_DECLARE_BUFFER(type, name, size) \
char *__##name[size + get_dcache_line_size()]; \
type *name = ALIGN_ADDR(__##name);
int mmc_startup(struct mmc *mmc)
{
/* Some declarations */
/* char ext_csd[512]; */
DMA_DECLARE_BUFFER(char, ext_csd, 512);
printf("%s: ptr:%p\n", __func__, ext_csd);
/* rest of the code */
}
Here the DMA_DECLARE_BUFFER really defines the buffer as an automatic
variable with this function scope. This is tested and works :-)
>
> > 4. get_dcache_line_size() can be simply defined as
> > #define get_dcache_line_size() CONFIG_SYS_CACHE_LINE_SIZE if we
> > _really_ want to save a few bytes.
>
> Actually I fail to understand why we would ever need
> get_dcache_line_size() in a boot loader.
If I can ask for clarification here.
Shall not u-boot read on fly the cache line size (as it is now done) or
you don't like the get_cache_line_size defined as function?
Going further shall the get_cache_line_size be removed completely and
replaced with CONFIG_SYS_CACHE_LINE_SIZE?
>
> Best regards,
>
> Wolfgang Denk
>
--
Best regards,
Lukasz Majewski
Samsung Poland R&D Center
Platform Group
More information about the U-Boot
mailing list