[U-Boot] [RFC/PATCH] common/usb: use cache-alligned buffers
Ilya Yanok
yanok at emcraft.com
Sun Oct 30 23:06:37 CET 2011
Hi Mike,
On 27.10.2011 02:20, Mike Frysinger wrote:
>> What do you think, how should we deal with it? Make all buffers
>> alligned or implement bounce-buffering inside host driver?
>
> since this is a common issue to most USB controllers, aligning the
> buffers is probably best. and should be relatively painless.
I agree with 'best' part but doubt about 'painless'.
> what's the code size before/after your change ?
[u-boot (mcx-new)]$ ls -l u-boot.bin-*
-rw-rw-r-- 1 yanok yanok 314248 окт. 30 22:55 u-boot.bin-after
-rw-rw-r-- 1 yanok yanok 314020 окт. 30 22:52 u-boot.bin-before
It's 248 bytes. But please note that this is only common/usb.c that has
buffers aligned with my patch. We also need to fix all other code that
passes buffers to HCD (for ex. for USB storage that means that we have
to fix usb_storage itself as well as partition support and FS driver).
And even with that we still will need some bounce buffer to handle the
situation with unaligned address passed by user...
>> --- a/common/usb.c
>> +++ b/common/usb.c
>>
>> -static struct devrequest setup_packet;
>> +static uchar __setup_packet[ALIGN(sizeof(struct devrequest),
>> + ARCH_DMA_MINALIGN)]
>> + __aligned(ARCH_DMA_MINALIGN);
>> +static struct devrequest * const setup_packet =
>> + (struct devrequest *)&__setup_packet;
>
> i'm not sure about this. why won't this work ?
> static struct devrequest setup_packet __aligned(ARCH_DMA_MINALIGN);
Well, we have to align both start address and size for safe cache
operations and my understanding is that __aligned gives up only start
address not size. Please correct me if I'm wrong.
Regards, Ilya.
More information about the U-Boot
mailing list