public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ilya Yanok <yanok@emcraft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC/PATCH] common/usb: use cache-alligned buffers
Date: Mon, 31 Oct 2011 02:06:37 +0400	[thread overview]
Message-ID: <4EADCA6D.6080100@emcraft.com> (raw)
In-Reply-To: <CAJaTeTriXCJNMrt59J62RbQwk61RQVFzqQfqTnB9M3KjnEDdBA@mail.gmail.com>

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.

      reply	other threads:[~2011-10-30 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-26 21:05 [U-Boot] [RFC/PATCH] common/usb: use cache-alligned buffers Ilya Yanok
2011-10-26 22:20 ` Mike Frysinger
2011-10-30 22:06   ` Ilya Yanok [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EADCA6D.6080100@emcraft.com \
    --to=yanok@emcraft.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox